eMorpho Data Server Reference

eMorpho

Introduction

USB driver

bpi_device

Data structures

Overview

Module Constants

Controls

Statistics

Results

Histogram

List Mode

Oscilloscope Trace

Summation Weights

Time Slices

Two-bank List Mode

API

Overview

Data Server

Overview

USB and device driver

Summary

The file ftdi.py is the device driver and provides the interface (via ctypes) to libusb0.1, which is the user-space USB driver.

The file ftdi.py defines two small classes. The first, bpi_usb is instantiated by the emorpho_server (or any user client) to establish the connection to all attached eMorpho units. It only has three functions, and it is the find_all() function that makes the USB connection to the eMorpho devices. That function returns a dictionary of mca-class objects with the serial numbers as the keys.

For each attached eMorpho there will be one class mca object. The object only stores minimal information about the eMorpho: most importantly the USB-handle. The goal was to make this class completely transient, so that it is stateless and stores no data. Instead data are stored inside the eMorpho, and, of course, by the client application.

However, it is not practical open an close a USB interface for each communication, because of the associated time delay. Hence, the mca-class object stores the USB handles and keeps the USB communication open.

bpi_usb Class Functions

bpi_usb Class Functions
FunctionDescription
scan_all()Count the number of attached eMorphos, but do nothing else. This can be done at any time without disturbing the open USB communication channels.
find_all()Find all attached eMorphos, claim the USB interfaces and open for communication. The function returns a dictionary of mca-class objects with the serial numbers as the key.
close_all()The bpi_usb class stores a copy of all USB handles. As a last resort, a client can delete their mca-class object dictionary and use close_all() to close all USB communications in order to start afresh.
Description of the bpi_usb class.

mca-class Class Functions

The functions of the mca-class are hardware dependent functions for I/O and configuration that are of little interest to the regular user.

mca Class Functions
FunctionDescription
read_data(bytes_per_datum)Read data from the FT245RL USB interface chip of the eMorpho. It strips the modem bytes from the data stream and assembles bytes into uint16 words or uint32 longs, depending on the bytes_per_datum argument (2 or 4)
write_data()Writes data from the mca.bytes_out buffer to the FT245RL USB interface chip of the eMorpho.
The two I/O functions of the mca-class.
mca Class Data
ItemDescription
bytes_outByte array used to send data to the eMorpho
num_bytesNumber of bytes to read
bytes_inA dynamically allocated byte array to receive the read data.
data_in_listReconstructed 2-byte or 4-byte data are stored in this list. The meaning of these raw data depends on which data structure the client wanted to read. The emorpho_api layer uses the functions of the io_obj that was used when reading the data to convert the raw data and populate the data_in_dict dictionary.
data_in_dictThis dictionary is loaded with data data organized into three keys: 'registers', 'fields' and 'user'. These are the three keys shown in the documentation for each data structure.
cmd_out_listHardware dependent communication header; Reserved.
Data stored in the mca-class.