CVMUSB

Name

CVMUSB -- Interface with VM-USB controller.

Synopsis


        #include <CVMUSB.h>

        class CVMUSB {
        
        
  static  std::vector<struct usb_device*> enumerate();
          static std::string serialNo(usb_device* dev);
        
  CVMUSB(struct usb_device* vmUsbDevice);
          void writeActionRegister(uint16_t value);
          uint32_t readFirmwareID();
          void writeGlobalMode(uint16_t value);
          uint16_t readGlobalMode();
          void writeDAQSettings(uint32_t value);
          uint32_t readDAQSettings();
          void writeLEDSource(uint32_t value);
          uint32_t readLEDSource();
          void writeDeviceSource(uint32_t value);
          uint32_t readDeviceSource();
          void writeDGG_A(uint32_t value);
          uint32_t readDGG_A();
          void writeDGG_B(uint32_t value);
          uint32_t readDGG_B();
          void writeDGG_Extended(uint32_t value);
          uint32_t readDGG_Extended();
          uint32_t readScalerA();
          uint32_t readScalerB();
          void writeVector(int which, uint32_t value);
          uint32_t readVector(int which);
          void writeIrqMask(uint8_t mask);
          uint8_t readIrqMask();
          void writeBulkXferSetup(uint32_t value);
          uint32_t readBulkXferSetup();
          int vmeWrite32(uint32_t address, uint8_t aModifier, uint32_t data);
          int vmeRead32(uint32_t address, uint8_tM aModifier, uint32_t* data);
          int vmeWrite16(uint32_t address, uint8_t aModifier, uint16_t data);
          int vmeRead16(uint32_t address, uint8_t aModifier, uint16_t*M data);
          int vmeWrite8(uint32_t address, uint8_t aModifier, uint8_t data);
          int vmeRead8(uint32_t address, uint8_t aModifier, uint8_t* data);
          int vmeBlockRead(uint32_t baseAddress, uint8_t aModifier, void* data, size_t transferCount, size_t* countTransferred);
          int vmeFifoRead(uint32_t address, int8_t aModifier, void* data, size_t transferCount, size_t* countTransferred);
          int vmeReadBlockCount8(uint32_t address, uint32_t mask, uint8_t amod);
          int vmeReadBlockCount16(uint32_t address, uint32_t mask, uint8_t amod);
          int vmeReadBlockCount32(uint32_t addressM, uint32_t mask, uint8_t amod);
          int vmeVariableBlockRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred);
          int vmeVariableFifoRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred);
          int executeList(CVMUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);
          int loadList(uint8_t listNumber, CVMUSBReadoutList& list, off_t listOffset =  0);
          int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);
          void setDefaultTimeout(int ms);
        
        class CVMUSB::RegisterOffsets  {
          static const unsigned int FIDRegister = 0;
          static const unsigned int GMODERegister = 4;
          static const unsigned int DAQSetRegister = 8;
          static const unsigned int LEDSrcRegister = 0xc;
          static const unsigned int DEVSrcRegister = 0x10;
          static const unsigned int DGGARegister = 0x14;
          static const unsigned int DGGBRegister = 0x18;
          static const unsigned int ScalerA = 0x1c;
          static const unsigned int ScalerB = 0x20;
          static const unsigned int ExtractMask = 0x24;
          static const unsigned int ISV12 = 0x28;
          static const unsigned int ISV34 = 0x2c;
          static const unsigned int ISV56 = 0x30;
          static const unsigned int ISV78 = 0x34;
          static const unsigned int DGGExtended = 0x38;
          static const unsigned int USBSetup = 0x3c;
          static const unsigned int USBVHIGH1 = 0x40;
          static const unsigned int USBVHIGH2 = 0x44;

        };
        class CVMUSB::ActionRegister {
          static const uint16_t startDAQ = 1;
          static const uint16_t usbTrigger = 2;
          static const uint16_t clear = 4;
          static const uint16_t sysReset = 8;
          static const uint16_t scalerDump = 0x10;
          static const uint16_t triggerL0 = 0x100;
          static const uint16_t triggerL1 = 0x200;
          static const uint16_t triggerL2 = 0x400;
          static const uint16_t triggerL3 = 0x800;
          static const uint16_t triggerL4 = 0x1000;
          static const uint16_t triggerL5 = 0x2000;
          static const uint16_t triggerL6 = 0x4000;
          static const uint16_t triggerL7 = 0x8000;
    };
    class CVMUSB::FirmwareRegister {
          static const uint32_t minorRevMask = 0x000000ff;
          static const uint32_t minorRevShift = 0;
          static const uint32_t majorRevMask = 0x0000ff00M;
          static const uint32_t majorRevShift = 8;
          static const uint32_t betaVersionMask = 0x00ff0000;
          static const uint32_t betaVersionShift = 16;
          static const uint32_t yearMask = 0x0f000000;
          static const uint32_t yearShift = 24;
          static const uint32_t monthMask = 0xf0000000;
          static const uint32_t monthshift = 27;
    };
    class CVMUSB::GlobalModeRegister {
      static const uint16_t bufferLenMask = 0xf;
      static const uint16_t bufferLenShift = 0;
      static const uint16_t bufferLen13K = 0;
      static const uint16_t bufferLen8K = 1;
      static const uint16_t bufferLen4K = 2;
      static const uint16_t bufferLen2K = 3;
      static const uint16_t bufferLen1K = 4;
      static const uint16_t bufferLen512 = 5;
      static const uint16_t bufferLen256 = 6;
      static const uint16_t bufferLen128 = 7;
      static const uint16_t bufferLen64 = 8;
      static const uint16_t bufferLenSingle = 9;
      static const uint16_t spanBuffers = 0x10;
      static const uint16_t mixedBuffers = 0x20;
      static const uint16_t doubleSeparator = 0x40;
      static const uint16_t align32 = 0x80;
      static const uint16_t doubleHeader = 0x100;
      static const uint16_t flushScalers = 0x200;
      static const uint16_t busReqLevelMask = 0x7000;
      static const uint16_t busReqLevelShift = 12;
    };
    class CVMUSB::DAQSettingsRegister {
      static const uint32_t readoutTriggerDelayMask = 0xff;
      static const uint32_t readoutTriggerDelayShift = 0;
      static const uint32_t scalerReadoutPeriodMask = 0xff00;
      static const >uint32_t scalerReadoutPeriodShift = 8;
      static const uint32_t scalerReadoutFrequenyMask = 0xffff0000;
      static const uint32_t scalerReadoutFrequencyShift = 16;
    };
    class CVMUSB::LedSourceRegister {
      static const uint32_t topYellowOutFifoNotEmpty = 0;
      static const uint32_t topYellowInFifoNotEmpty = 1;
      static const uint32_t topYellowScalerEvent = 2;
      static const uint32_t topYellowInFifoFull = 3;
      static const uint32_t topYellowDTACK = 4;
      static const uint32_t topYellowBERR = 5;
      static const uint32_t topYellowBusRequest = 6;
      static const uint32_t topYellowBusGranted = 7;
      static const uint32_t topYellowInvert = 0x8;
      static const uint32_t topYellowLatch = 0x10;
      static const uint32_t redEventTrigger = (0 << 8);
      static const uint32_t redNimInput1 = (1 << 8);
      static const uint32_t redNimInput2 = (2 << 8);
      static const uint32_t redBusyM = (3 << 8);
      static const uint32_t redDTACK = (4 << 8);
      static const uint32_t redBERR = (5 << 8);
      static const uint32_t redBusRequest = (6 << 8);
      static const uint32_t redBusGranted = (7 << 8);
      static const uint32_t redInvert = (8 << 8);
      static const uint32_t redLatch = (0x10 << 8);
      static const uint32_t greenAcquire = (0 << 16);
      static const uint32_t greenStackNotEmpty = (1 << 16);
      static const uint32_t greenEventReady = (2 << 16);
      static const uint32_t greenEventTrigger = (3 << 16);
      static const uint32_t greenDTACK = (4 << 16);
      static const uint32_t greenBERR = (5 << 16);
      static const uint32_t greenBusRequest = (6 << 16);
      static const uint32_t greenBusGranted = (7 << 16);
      static const uint32_t greenInvert = (8 << 16);
      static const uint32_t greenLatch = (0x10 << 16);
      static const uint32_t bottomYellowNotArbiter = (0 << 24);
      static const uint32_t bottomYellowUsbTrigger = (1 << 24);
      static const uint32_t bottomYellowUSBReset = (2 << 24);
      static const uint32_t bottomYellowBERR1 = (3 << 24);
      static const uint32_t bottomYellowDTACK = (4 << 24);
      static const uint32_t bottomYellowBERR = (5 << 24);
      static const uint32_t bottomYellowBusRequest = (6 << 24);
      static const uint32_t bottomYellowBusGranted = (7 << 24);
      static const uint32_t bottomYellowInvert = (8 << 24);
      static const uint32_t bottomYellowLatch = (0x10 << 24);
    };
    class CVMUSB::DeviceSourceRegister {
      static const uint32_t nimO1Busym = 0;
      static const uint32_t nimO1Trigger = 1;
      static const uint32_t nimO1BusRequest = 2;
      static const uint32_t nimO1EventToBuffer = 3;
      static const uint32_t nimO1DGGA = 4;
      static const uint32_t nimO1DGGB = 5;
      static const uint32_t nimO1EndOfEvent = 6;
      static const uint32_t nimO1UsbTrigger = 7;
      static const uint32_t nimO1Invert = 8M;
      static const uint32_t nimO1Latch = 0x10;
      static const uint32_t nimO2UsbTrigger1 = (0 << 8);
      static const uint32_t nimO2VMEExecuting = (1 << 8);
      static const uint32_t nimO2VMEAS = (2 << 8);
      static const uint32_t nimO2DataToUsbFIFO = (3 << 8);
      static const uint32_t nimO2DGGA = (4 << 8);
      static const uint32_t nimO2DGGB = (5 << 8);
      static const uint32_t nimO2EndOfEvent = (6 << 8);
      static const uint32_t nimO2UsbTrigger = (7 << 8);
      static const uint32_t nimO2Invert = (8 << 8);
      static const uint32_t nimO2Latch = (0x10 << 8);
    
    
    
      static const uint32_t scalerADGGA = (0   << 16);
      static const uint32_t scalerANIMI1 = (1   << 16);
      static const uint32_t scalerANIMI2 = (2   << 16);
      static const uint32_t scalerAEvent = (3   << 16);
      static const uint32_t scalerAEnable = (8   << 16);
      static const uint32_t scalerAReset = (0x10 << 16);
      static const uint32_t scalerBCarryA = (0   << 20);
      static const uint32_t scalerBNIMI1 = (1   << 20);
      static const uint32_t scalerBNIMI2 = (2   << 20);
      static const uint32_t scalerBEvent = (3   << 20);
      static const uint32_t scalerBEnable = (8   << 20);
      static const uint32_t scalerBReset = (0x10 << 20);
      static const uint32_t dggADisabled = (0   << 24);
      static const uint32_t dggANIMI1 = (1   << 24);
      static const uint32_t dggANIMI2 = (2   << 24);
      static const uint32_t dggAEventTrigger = (3   << 24);
      static const uint32_t dggAEndOfEvent = (4   << 24);
      static const uint32_t dggAUsbTrigger = (5   << 24);
      static const uint32_t dggAPulser = (6   << 24);
      static const uint32_t dggBDisabled = (0   << 28);
      static const uint32_t dggBNIMI1 = (1   << 28);
      static const uint32_t dggBNIMI2 = (2   << 28);
      static const uint32_t dggBEventTrigger = (3   << 28);
      static const uint32_t dggBEndOfEvent = (4   << 28);
      static const uint32_t dggBUsbTrigger = (5   << 28);
      static const uint32_t dggBPulser = (6   << 28);
      static const uint32_t freezeScalers = 0x80000000;
    };
    class CVMUSB::DGGAndPulserRegister {
          static const uint32_t dggFineDelayMask = 0xffff;
          static const uint32_t dggFineDelayShift = 0;
          static const uint32_t dggGateWidthMask = 0xffff0000;
          static const uint32_t dggGateWidthShift = 16;
    
    };
    class CVMUSB::DGGCoarseRegister {
          static const uint32_t ACoarseMask = 0xffff;
          static const uint32_t ACoarseShift = 0;
          static const uint32_t BCoarseMask = 0xffff0000;
          static const uint32_t BCoarseShift = 16;
    
    }; 
    class CVMUSB::ISVRegister {
          static const uint32_t AVectorMask = = 0xff;
          static const uint32_t AVectorShift = 0;
          static const uint32_t AIPLMask = 0x700;
          static const uint32_t AIPLShift = 8;
          static const uint32_t AStackIDMask = 0x7000;
          static const uint32_t AStackIDShift = 12;
          static const uint32_t BVectorMask = 0xff0000;
          static const uint32_t BVectorShift = 16;
          static const uint32_t BIPLMask = 0x7000000;
          static const uint32_t BIPLShift = 24;
          static const uint32_t BStackIDMask = 0x70000000;
          static const uint32_t BStackIDShift = 28;
    };
    class CVMUSB::TransferSetupRegister {
          static const uint32_t multiBufferCountMask = 0xff;
          static const uint32_t multiBufferCountShift = 0;
          static const uint32_t timeoutMask = 0xf00;
          static const uint32_t timeoutShift = 8;
    };
    



};
        

DESCRIPTION

CVMUSB encapsulates a VM-USB controller. Its methods are divided in to several categories:

See METHODS below for descriptions of each of the methods.

Register bits and field definitions are provided as nested classes see CONSTANTS below for a description of each of these classes.

METHODS

This section provides a description of each of the methods. Where appropriate reference is made to sections of the VM-USB manual.

static std::vector<struct usb_device*> enumerate();

This function returns a vector of usb_device* pointers, one for each VM-USB powered up and attached to the system. usb_device is an opaque type used by libusb to refer to a specific device attached to the host via USB.

static std::string serialNo(usb_device* dev);

Given a usb_device pointer, typically] gotten from CVMUSB::enumerate, returns the serial number string of the device that corresponds to it.

CVMUSB(struct usb_device* vmUsbDevice);

Constructs a CVMUSB object given a usb_device pointer typically gotten from CVMUSB::enumerate

void writeActionRegister(uint16_t value);

Writes value to the VM-USB action register. The action register is a write only register that is used to control the overall behavior of the VM-USB. It allows you to enter or leave data taking mode, reset the VME bus and trigger the various downloaded VME lists.

The action register is described in section 3.1 of the VM-UBS manual.

uint32_t readFirmwareID();

Reads the firmware Id register. The firmware Id is a bit encoded readonly register that provides the date, status (beta test or production), the major and minor versions of the firmware. The firmware Id register is described by section 3.4.1 of the VM-USB manual.

void writeGlobalMode(uint16_t value);

Writes value to the VM-USB global mode regiseter. The global mode register determiens the bus request level, header options and the size of the output buffer, as well as a few other buffer options. It is described in setion 3.4.2 of the VM-USB manual.

uint16_t readGlobalMode();

Returns the value of the global mode register.

void writeDAQSettings(uint32_t value);

Writes the data acquisition settings register with value. This register, described in section 3.4.3 of the VM-USB manual, determines how scaler buffers are read and the delay between a readout trigger from IN1 and the actual start of VME list execution. This is provided to allow users to provide a common digitizer and VM-USB trigger. The delay, in that case allows digitizers to complete their conversions prior to being read by the readout list.

uint32_t readDAQSettings();

Returns the value of the data acquisition settings register.

void writeLEDSource(uint32_t value);

Write value to the VM-USB LED source register. The VM-USB has a set of four LEDs. This register determines the conditions under which each of those LEDs is lit. The LED source register is described in section 3.4.4 of the VM-USB manual.

uint32_t readLEDSource();

Returns the current value of the LED source register.

void writeDeviceSource(uint32_t value);

Writes value to the VM-USB device source register. The VM-USB provides a pair of scalers and gate and delay generators, as well as two front panel NIM outputs. This register defines the signal sources for each of these devices (when scalers increment, what starts a gate and delay generator and when the outputs are asserted).

The Device Sources register is described in section 3.4.5 of the VM-USB manual.

uint32_t readDeviceSource();

Returns the value of the Device source register.

void writeDGG_A(uint32_t value);

Writes value to the Delay and Gate Generator A control register. This register contains the length of the output gateas well as the low order bits of the delay. The Delay and Gate register setup is described in section 3.4.6 of the VM-USB manual.

uint32_t readDGG_A();

Returns the value of the DGG A control register.

void writeDGG_B(uint32_t value);

Writes value to the Delay and Gate Generator B control register. This register contains the length of the output gateas well as the low order bits of the delay. The Delay and Gate register setup is described in section 3.4.6 of the VM-USB manual.

uint32_t readDGG_B();

Returns the value of the DGG B control register.

void writeDGG_Extended(uint32_t value);

Writes the DGG extended delay offset. This register contains the top 16 bits of the delay for both A and B DGG's. It is describedin section 3.4.6 of the VM-USB manual.

uint32_t readDGG_Extended();

Reads the DGG extended delay register.

uint32_t readScalerA();

The VM-USB contains two scalers (counters) that can be incremented as a result of several conditions. These scalers are named A and B and are described in section 3.4.7 of the VM-USB manual.

This method returns the value of scaler A.

uint32_t readScalerB();

See readScalerA this method returns the value of scaler B.

void writeVector(int which, uint32_t value);

The VM-USB allows stacks to be triggered as a result of VME interrupts. 4 interrupt registers are provided as described in section 3.4.8. Each register describes the IPL and Status ID of two interrupts and associates each of those with a stack. This method allows you to program the value of one of those registers.

The which parameter selects which of the interrupt registers to write, numbered from 1 through 4. The value parameter is written to the selected register.

An error message is thrown as an std::string if which is illegal.

As essentially all VME interrupters in existence use an 8 bit status ID for which the top bits must be set, according to the VME standard, These methods also write both Status/ID expansion registers to 0xffffffff

uint32_t readVector(int which);

Returns the value of one of the interrupt registers described above. which indicates which one to read.

void writeIrqMask(uint8_t mask);

Writes the IRQ mask register described in section 3.5 of the VM-USB manual. The register is set to mask. Each bit in the mask represents a VME IPL. 0x01 represents IPL1, 0x40 represents IPL 7. If a bit is set to 1, interrupts at that IPL will be ignored by the VM-USB.

This register only needs to be programmed when the VM-USB is used with other interrupt handling modules (e.g. CPU modules).

uint8_t readIrqMask();

Returns the value last written to the IRQ mask register. The actual register is write-only. The CVMUSB class therefore remembers the most recently written value. This shadow register value is what is returned by this method. Note as well that the IRQ mask register is set to 0xff by the constructor so that it has a known intial value. This initial value disables all interrupt handling by the VM-USB.

void writeBulkXferSetup(uint32_t value);

Writes value to the Bulk Transfer setup register. This register is described in section 3.4.10 of the VM-USB manual. It controls several parameters that can optimize the bandwidth of the USB. Specifically you can set the number of buffers that will be sent from the VM-USB to the host without generating a USB Packet end frame and the timeout after which the packet end frame will be sent regardless of how many bufers were sent.

If the paragraph above is not meaningful to you, and you read 3.4.10 and its still not meaningful, you should probably not touch this register.

uint32_t readBulkXferSetup();

Returns the value of the Bulk Transfer Setup register.

int vmeWrite32(uint32_t address, uint8_t aModifier, uint32_t data);

Writes a 32 bit longword, data to a vme address using the VME Address modifier aModifier.

The function returns 0 on success, -1 if the USB write failed, -2 if the USB read of the acknowledgement failed, and -3 if the acknowledgement packet indicated the transfer failed due to a bus error.

For USB write and read failures, the resason for the failure is available in errno

int vmeRead32(uint32_t address, uint8_tM aModifier, uint32_t* data);

Performs a 32 bit longword read from address using the VME bus address modifier aModifier. If successful, the data are stored in data.

The return value reflects a high level status of the operation. The function returns 0 on success, -1 if the USB write failed, -2 if the USB read of the acknowledgement failed.

For USB write and read failures, the resason for the failure is available in errno

int vmeWrite16(uint32_t address, uint8_t aModifier, uint16_t data);

Identical to vmeWrite32 however the data transfered is only a 16 bit word wide.

int vmeRead16(uint32_t address, uint8_t aModifier, uint16_t*M data);

Identical to vmeRead32 however the data read are only a 16 bit word wide.

int vmeWrite8(uint32_t address, uint8_t aModifier, uint8_t data);

Same as vmeWrite32 however the data written are an 8 bit byte in width.

int vmeRead8(uint32_t address, uint8_t aModifier, uint8_t* data);

Same as vmeRead32 however the data read are an 8 bit byte in width.

int vmeBlockRead(uint32_t baseAddress, uint8_t aModifier, void* data, size_t transferCount, size_t* countTransferred);

Performs a block read from the VME bus. VME block reads the requestor to only send an initial VME base address followed by a new address every time the address crosses a 256 byte boundary. Subsequent addresses are assumed to represent a contiguous block of storage. Not all devices support block transfers. Block transfers also require specific block transfer address modifiers. When used properly, block transfers allow higher throughput by reducing the number of address cycles.

The base address of the block transfer is baseAddress. The address modifier used is aModifier the caller is responsible for ensuring that aModifier is a valid block transfer address modifier. data is a buffer that will receive the data read. transferCount is the number of longwords (32 bit items) to transfer. All transfers will be 32 bit wide transfers. countTransferred will be the actual number of longwords transferred.

For some devices it is possible to transfer fewer items thatn the number of items requested. An example of this is the use of CAEN V785's in chained block mode. In that case, the read will transfer data until the ADC's have no more data left at which time the modules will return a bus error on the next transfer and the VM-USB will insert a 0xffffffff marker in the data stream when the bus error occured.

int vmeFifoRead(uint32_t address, int8_t aModifier, void* data, size_t transferCount, size_t* countTransferred);

This function is the same as vmeBlockRead except that all address cycles use the same address value. This makes the function suitable to read FIFO registers in modules that support block reads.

int vmeReadBlockCount8(uint32_t address, uint32_t mask, uint8_t amod);

The VM-USB supports variable sized block reads. These operate by first performing a read of the block count from some register and providing a mask that indicates what part of that data contains the transfer count. The block count read must at some point be folowed by a call to vmeVariableBlockRead to actually perform the block read.

This method does an 8 bit transfer to read the block count for the next vmeVariableBlockRead call. address is the byte address of the location that contains the count field. The addressed module must support byte addressing at this location. mask is the mask that defines the bit field containing the count. amod is the address modifier for the transfer of the transfer count.

int vmeReadBlockCount16(uint32_t address, uint32_t mask, uint8_t amod);

Same as vmeReadBlockCount8 but the block count transfer is 16 bits wide.

int vmeReadBlockCount32(uint32_t addressM, uint32_t mask, uint8_t amod);

Same as vmeReadouBlockCount8 except the block count is read with a 32 bit transfer.

int vmeVariableBlockRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred);

Do a variable length block transfer. This transfer must have been set up by doing a call to one of the vmeReadBlockCountxx functions. furthermore, no other block transfer can have taken place since that operation. It is strongly recommended that unless prohibited by the hardware, a vmeReadBlockCountxx be immediately followed by a variable block read or variable fifo read.

address is the starting address of the block read. amod is the VME address modifier. data is a buffer into which data will be stored and maxCount the size of that buffer in 32bit longwords. countTransferred will be filled in with the total number of longwords actually transferred.

The total transfer count is the minimum of the variable block read gotten by the vmeReadBlockCountxx method, the value of the maxCount parameter to this call and the number of transfers actually performed prior to and including the transfer that caused a bus error if any.

As usual, in the event the transfer terminated with a bus error, that operation inserts a 0xffffffff in the buffer.

int vmeVariableFifoRead(uint32_t address, uint8_t amod, void* data, size_t maxCount, size_t* countTransferred);

Same as vmeVariableBlockRead but all addresses cycles provide address rather than

int executeList(CVMUSBReadoutList& list, void* pReadBuffer, size_t readBufferSize, size_t* bytesRead);

This function executes a list of operations. The list parameter is an instance of a CVMUSBReadoutList class. See the documentation for that class for a description of how to build up lists of VM-USB operations.

pReadBuffer points to a buffer into which the results of all VME read operations will be put. The buffer must be readBufferSize 8 bit bytes long. bytesRead will be written with the number of bytes actually transferred to pReadBuffer

int loadList(uint8_t listNumber, CVMUSBReadoutList& list, off_t listOffset = 0);

Loads a list for triggered execution in data taking mode. listNumber is the number of the list to load (stack Number). Tis is a value in the range [0..7]. list is a list of operations built up by instantiating a CVMUSBReadoutList

listOffset is the starting offset in VM-USB memory at which the list should be loaded. When computing where to load multiple stacks you need to know that each stack requires:


list.size() * sizeof(uint32_t)/sizeof(uint16_t) + 4
                                

locations.

int usbRead(void* data, size_t bufferSize, size_t* transferCount, int timeout = 2000);

Performs a bulk read on the VM-USB. data provides a buffer into which the data will be read. bufferSize is the number of bytes of space pointed to by data transferCount will be written with the number of transfers that actually were performed.

The return value is 0 on success or -1 on failure. On failure, zero will be stored in the transferCount and errno will have the reason for the failure.

If no data are available by timeout milliseconds, the read will fail with an errno value of ETIMEDOUT

void setDefaultTimeout(int ms);

Sets the timeout used for transactions that don't provide a timeout value. ms is the number of milliseconds these methods will wait for a response from the VM-USB.

Almost all actions with the VM-USB require the host to send a USB packet to the VM-USB and receive a packet in return. This function sets the timeout that will be used for the usbRead call to get the return packets.

CONSTANTS

This class defines a large number of nested classes. Each nested class defines symbolic constants for a register. The SYNOPSIS section shows these definitions.

For example, the CVMUSB::ActionRegister provides bit definitions fro the Action register.