classCCCUSBusb
: publicCCCUSB
{CCCUSBusb(struct usb_device* UsbDevice);
void writeActionRegister(uint16_t value);
int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
int loadList(uint8_t listNumber, CCCUSBReadoutList& list);
int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);
void setDefaultTimeout(int ms);
};
This class is the low level support for the Wiener/JTEC CCUSB module. the CCUSB is a USB CAMAC controller. To use this class you must first locate a module by invoking enumerate. enumerate returns a vector of usb_device*s. One of those can be used to instantiate the CCCUSBusb object which can the ben operated on.
Most all of the functionality is implemented in te base class CCCUSB. The methods defined in this class are the minimum needed to be implemented in order to attach to a locally connected usb device (i.e. the usb device is directly connected to the computer).
In the functions listed below, any function that returns an int
returns 0 on success, -1 if
the write operation to the device failed or -2
if the read operation failed. Negative values result in the
errno
variable set to the actual reason for the
failure.
CCCUSBusb(struct usb_device* ccUsbDevice);
Constructs a CCCUSB
object.
The resulting object can be used to communicate
with the CC-USB represented by the
ccUsbDevice
object.
void writeActionRegister(uint16_t value);
Writes the CCUSB's action register. The class also supplies symoblic definitions for bits in the action register. See the Action register section of PUBLIC VARIABLES, TYPES and CONSTANTS below.
int executeList(CCCUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
Performs a CAMAC list operation in immediate mode.
In order to do this data taking mode must not
be on. The list
is built up
by constructing a CCCUSBReadoutList
(see CCCUSBReadoutList(3ccusb))
object and using its methods to add the appropriate
set of instructions to the list.
pReadBuffer
is a pointer to
a buffer you have prepared to receive the results
of the read operations in the list. This buffer
has readBufferSize
bytes
of data. On successful return,
bytesRead
will contain the
actual number of bytes transferred into your buffer.
On failure (return value other than 0),
the value of bytesRead
is not
well defined.
int loadList(uint8_t listNumber, CCCUSBReadoutList& list);
Loads a list into the CC-USB. The listNumber
must be 0 for the event list and 1 for the scaler list.
If it is any value other than this, the function
will return -4.
list
is the
CCCUSBReadoutList
to load.
See CCCUSBReadoutList(3ccusb) for
information about this parameter and how to build it.
int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);
Pefroms a bulk read on the data transfer endpoint
of the CC-USB. Normally this only needs to be called
by the CCUSBReadout framework when in data taking mode.
data
is a buffer
into which data read should be transferred.
bufferSize
is the number
of bytes that can be stored in buffer
transferCount
points to a
buffer that will contain the number of bytes actually
transferred to the buffer. timeout
is the number of milliseconds to wait for the transfer
to complete before ending with a timeout condition.
void setDefaultTimeout(int ms);
Most of the immediate operations require a write to the
CC-USB followed by a read to get status and/or data.
This function allows you to override the default
timeout for the read. ms
is
the number of milliseconds in the new timeout.
Normally you will not need to call this.