Cat
Public Types | Public Member Functions | Private Attributes | List of all members
UsbFTInterface Class Reference

#include <include/UsbFTInterface.h>

Inheritance diagram for UsbFTInterface:
Interface Element Hierarchy Object Attrib

Public Types

enum  WordSize { WS_Byte =1, WS_Word, WS_DWord }
 
enum  IOMode {
  USB_IORead, USB_IOWrite, USB_IOReadWrite, USB_WriteReadBurst,
  USB_IOExtebdedRead
}
 
typedef unsigned long U32
 
typedef unsigned short U16
 
typedef unsigned char U8
 
- Public Types inherited from Attrib
enum  Attribut {
  UNDEFINED, PASSIVE, ACTIVE, INTERFACE,
  IO, IODATA, ELEMENT, HARDWARE,
  PROCESSUS, SOFTWARE
}
 

Public Member Functions

 UsbFTInterface ()
 
virtual ~UsbFTInterface ()
 
virtual void help ()
 
virtual StatusCode init ()
 
void close ()
 
virtual void reset ()
 
virtual void update ()
 
StatusCode read (IOdata *)
 
StatusCode write (IOdata *)
 
StatusCode read (unsigned long int, unsigned long int, boost::python::list &)
 
StatusCode write (unsigned long int, boost::python::list)
 
StatusCode usbRead (unsigned long int, unsigned long int, std::vector< U32 > &)
 
StatusCode usbWrite (unsigned long int, std::vector< U32 >)
 
StatusCode usbReadU8 (unsigned long int, unsigned long int, unsigned char *)
 
StatusCode usbReadU16 (unsigned long int, unsigned long int, unsigned short *)
 
StatusCode usbReadU32 (unsigned long int, unsigned long int, unsigned long *)
 
StatusCode usbWriteU8 (unsigned long int, unsigned long int, unsigned char *)
 
StatusCode usbWriteU16 (unsigned long int, unsigned long int, unsigned short *)
 
StatusCode usbWriteU32 (unsigned long int, unsigned long int, unsigned long *)
 
StatusCode usbWriteRead (unsigned long int, std::vector< U8 >, std::vector< U8 > &)
 
void setUsbId (int usbId)
 
int usbId ()
 
void setSerialNum (std::string serialNum)
 
std::string serialNum ()
 
void setDeviceDesc (std::string deviceDesc)
 
std::string deviceDesc ()
 
void setLatencyTimer (unsigned char latencyTimer)
 
unsigned char latencyTimer ()
 
void setTimeOut (int txTimeOut, int rxTimeOut)
 
int txTimeOut ()
 
int rxTimeOut ()
 
void setBuffer (int txBuffer, int rxBuffer)
 
int txBuffer ()
 
int rxBuffer ()
 
void setNFrames (long int nFrames)
 
long int nFrames ()
 
void setWordCount (unsigned long wordCount)
 
unsigned long wordCount ()
 
void setWordSize (unsigned long wordSize)
 
unsigned long wordSize ()
 
void setFakeErr (unsigned int fakeErr)
 
unsigned int fakeErr ()
 
void setInterrupts (bool interrupts)
 
bool interrupts ()
 
void setShowEpromState (bool showEpromState)
 
bool showEpromState ()
 
bool wrBlockMax ()
 
void setWrBlockMax (bool wrBlockMax)
 
bool rdBlockMax ()
 
void setRdBlockMax (bool rdBlockMax)
 
void setPrintout (bool printout)
 
bool printout ()
 
- Public Member Functions inherited from Interface
 Interface ()
 Standard constructor. More...
 
virtual ~Interface ()
 Destructor. More...
 
- Public Member Functions inherited from Element
 Element ()
 Standard constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
void recursiveInitElement ()
 
void recursiveInitCommunications ()
 
StatusCode setConnection (Hierarchy *)
 
Hierarchyconnection ()
 
- Public Member Functions inherited from Hierarchy
 Hierarchy ()
 Standard constructor. More...
 
virtual ~Hierarchy ()
 Destructor. More...
 
void clear ()
 
void setParent (Hierarchy *parent)
 
Hierarchyparent ()
 
Hierarchyparent (std::string)
 
Hierarchyorigin ()
 
virtual void addChild (Hierarchy *element)
 
std::vector< Hierarchy * > children ()
 
Hierarchychild (std::string)
 
HierarchychildTyped (std::string)
 
unsigned long numberOfChildren ()
 
bool hasChildren ()
 
void delChild (Hierarchy *)
 
void delChild (std::string)
 
std::string path (std::string=std::string(""))
 
std::string pathTyped (std::string=std::string(""))
 
void tree (std::string indent=std::string(""))
 
void tree ()
 
- Public Member Functions inherited from Object
 Object ()
 Standard constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string name () const
 
std::string type ()
 
unsigned char id ()
 
std::string title ()
 
void msgSvc (int level, std::string msg, std::string name)
 
void msg (std::string mymsg)
 
void verbose (std::string mymsg)
 
void debug (std::string mymsg)
 
void info (std::string mymsg)
 
void warning (std::string mymsg)
 
void error (std::string mymsg)
 
void fatal (std::string mymsg)
 
void msg (std::string mymsg, std::string name)
 
void verbose (std::string mymsg, std::string name)
 
void debug (std::string mymsg, std::string name)
 
void info (std::string mymsg, std::string name)
 
void warning (std::string mymsg, std::string name)
 
void error (std::string mymsg, std::string name)
 
void fatal (std::string mymsg, std::string name)
 
void setName (std::string name)
 
void setType (std::string type)
 
void setId (unsigned char id)
 
void setTitle (std::string title)
 
void setDllName (std::string dllName)
 
std::string dllName ()
 
- Public Member Functions inherited from Attrib
 Attrib ()
 Standard constructor. More...
 
virtual ~Attrib ()
 Destructor. More...
 
bool is (int attribut)
 
void add (int attribut)
 
void remove (int attribut)
 
std::string attributs ()
 

Private Attributes

int m_usbId
 
std::string m_serialNum
 
std::string m_deviceDesc
 
unsigned char m_latencyTimer
 
int m_txTimeOut
 
int m_rxTimeOut
 
int m_txBuffer
 
int m_rxBuffer
 
long int m_nFrames
 
unsigned long m_wordCount
 
unsigned long m_wordSize
 
unsigned int m_fakeErr
 
bool m_interrupts
 
bool m_showEpromState
 
bool m_printout
 
int m_rdBlockMax
 
int m_wrBlockMax
 

Additional Inherited Members

- Protected Attributes inherited from Element
Hierarchym_connection
 
- Protected Attributes inherited from Attrib
std::string m_attribString [10]
 

Detailed Description

Class to describe general electronics object

Author
Frederic Machefert
Date
2004-01-18

Definition at line 40 of file UsbFTInterface.h.

Member Typedef Documentation

◆ U16

typedef unsigned short UsbFTInterface::U16

Definition at line 43 of file UsbFTInterface.h.

◆ U32

typedef unsigned long UsbFTInterface::U32

Definition at line 42 of file UsbFTInterface.h.

◆ U8

typedef unsigned char UsbFTInterface::U8

Definition at line 44 of file UsbFTInterface.h.

Member Enumeration Documentation

◆ IOMode

Enumerator
USB_IORead 
USB_IOWrite 
USB_IOReadWrite 
USB_WriteReadBurst 
USB_IOExtebdedRead 

Definition at line 53 of file UsbFTInterface.h.

◆ WordSize

Enumerator
WS_Byte 
WS_Word 
WS_DWord 

Definition at line 46 of file UsbFTInterface.h.

Constructor & Destructor Documentation

◆ UsbFTInterface()

UsbFTInterface::UsbFTInterface ( )

Definition at line 19 of file UsbFTInterface.cpp.

References Object::info(), Object::setName(), and Object::setType().

19  :
20  m_usbId(-1),
21  m_serialNum(std::string("None")),
22  m_deviceDesc(std::string("None")),
23  m_latencyTimer(2),
24  m_txTimeOut(1000),
25  m_rxTimeOut(1000),
26  m_txBuffer(4096),
27  m_rxBuffer(32768),
28  m_nFrames (0),
31  m_rdBlockMax(32768),
32  m_wrBlockMax(256),
33  m_interrupts(true),
34  m_showEpromState(false),
35  m_printout(false)
36 {
37  setName("usb");
38  setType("UsbFTInterface");
39  info("Todo : time efficiency by creating the buffer once for all ?");
40  // add(Attrib::INTERFACE);
41 }
void info(std::string mymsg)
Definition: Object.h:38
void setName(std::string name)
Definition: Object.h:51
long int m_nFrames
unsigned long m_wordSize
void setType(std::string type)
Definition: Object.h:52
std::string m_deviceDesc
std::string m_serialNum
unsigned char m_latencyTimer
unsigned int m_fakeErr

◆ ~UsbFTInterface()

virtual UsbFTInterface::~UsbFTInterface ( )
inlinevirtual

Definition at line 63 of file UsbFTInterface.h.

References close().

63  {
64  close();
65  } //< Destructor

Member Function Documentation

◆ close()

void UsbFTInterface::close ( )

Close the usb device

Definition at line 802 of file UsbFTInterface.cpp.

References CloseUsbDevice(), Object::info(), itos(), m_usbId, and Object::name().

Referenced by BOOST_PYTHON_MODULE(), help(), init(), reset(), and ~UsbFTInterface().

802  {
803  if (m_usbId>0)
804  {
805  info("Close USB device "+name()+" [id="+itos(m_usbId)+"]","UsbFTInterface::close");
807  }
808  m_usbId=-1;
809 }
void info(std::string mymsg)
Definition: Object.h:38
std::string itos(int)
Definition: Tools.cpp:46
LALUSB_API void _cstmcall CloseUsbDevice(int id)
std::string name() const
Definition: Object.h:28

◆ deviceDesc()

std::string UsbFTInterface::deviceDesc ( )
inline

Get accessor to member m_deviceDesc

Returns
the current value of m_deviceDesc

Definition at line 272 of file UsbFTInterface.h.

References m_deviceDesc.

Referenced by BOOST_PYTHON_MODULE(), and setDeviceDesc().

272  {
273  return m_deviceDesc;
274  }
std::string m_deviceDesc

◆ fakeErr()

unsigned int UsbFTInterface::fakeErr ( )
inline

Get accessor to member m_fakeErr

Returns
the current value of m_fakeErr

Definition at line 409 of file UsbFTInterface.h.

References m_fakeErr.

Referenced by setFakeErr().

409  {
410  return m_fakeErr;
411  }
unsigned int m_fakeErr

◆ help()

virtual void UsbFTInterface::help ( )
inlinevirtual

printout help for the element

Implements Interface.

Definition at line 71 of file UsbFTInterface.h.

References close(), Object::info(), init(), and Object::name().

71 { info("UsbFTInterface "+name()+". No help.","UsbFTInterface::help"); };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28

◆ init()

StatusCode UsbFTInterface::init ( )
virtual

init the component

Returns
void

Implements Interface.

Definition at line 47 of file UsbFTInterface.cpp.

References close(), Object::error(), Object::fatal(), FT_OK, GetDeviceDesc(), GetDeviceSerNum(), Object::info(), itos(), m_deviceDesc, m_interrupts, m_latencyTimer, m_rxBuffer, m_rxTimeOut, m_serialNum, m_txBuffer, m_txTimeOut, m_usbId, Object::name(), OpenUsbDevice(), StatusCode::SUCCESS, USB_FindDevices(), USB_GetLastError(), USB_GetLatencyTimer(), USB_Init(), USB_Perror(), USB_SetLatencyTimer(), USB_SetTimeouts(), USB_SetXferSize(), UsbSetIntCheckingState(), and wait().

Referenced by BOOST_PYTHON_MODULE(), help(), and reset().

47  {
48  unsigned char msecs=0;
49  char desc[64];
50  char serial[9];
51 
52  strcpy(desc , m_deviceDesc.c_str());
53  strcpy(serial, m_serialNum.c_str());
54 
55  info("Start USB device initialisation.","UsbFTInterface::init");
56 
57  if (m_usbId>0)
58  {
59  error("Usb device already open.","UsbFTInterface::init");
60  close();
61  }
62  if (!USB_FindDevices(desc))
63  {
65  error("Cannot find Usb Device "+name()+" with device description "+
66  m_deviceDesc,"UsbFTInterface::init");
67  }
68  else
69  {
70  info("Device with device description "+m_deviceDesc+" found.","UsbFTInterface::init");
71  info("Try to open device with serial number "+m_serialNum+".","UsbFTInterface::init");
72  m_usbId=OpenUsbDevice(serial);
73  if (m_usbId<0)
74  {
75  error("Could not find device with serial number "+m_serialNum,"UsbFTInterface::init");
76  if (GetDeviceSerNum(serial,0)!=FT_OK)
77  {
78  error("Serial number do not match first device found.","UsbFTInterface::init");
79  }
80  else
81  {
82  info("Extracted serial number "+std::string(serial)+".","UsbFTInterface::init");
83  if (GetDeviceDesc(desc,0)!=FT_OK)
84  {
86  fatal("Device description do not match first device either. Abort",
87  "UsbFTInterface::init");
88  }
89  else
90  {
91  info("Device found. Extracted description "+std::string(desc)+".",
92  "UsbFTInterface::init");
93  m_usbId=OpenUsbDevice(serial);
94  if (m_usbId<0)
95  {
97  fatal("Cannot open device. Abort.","UsbFTInterface::init");
98  }
99  }
100  }
101  };
102  info("Device opened with UsbId "+itos(m_usbId)+".","UsbFTInterface::init");
103 
104  m_deviceDesc = std::string(desc);
105  m_serialNum = std::string(serial);
106 
108  if (!USB_Init(m_usbId,true))
109  {
111  fatal("Could not initialize the USB device "+name()+". Abort.",
112  "UsbFTInterface::init");
113  }
114 
115  info("Usb device initialization done.","UsbFTInterface::init");
116 
120  USB_GetLatencyTimer(m_usbId, &msecs);
121 
122  // USB_ResetDevice(m_usbId);
123 /*
124  if (USB_ReadEEpromData(m_usbId,m_showEpromState))
125  {
126  m_deviceDesc=std::string(USB_GetEpromDeviceDesc());
127  m_serialNum =std::string(USB_GetEpromSerialNum());
128  info("EPROM data : ","UsbFTInterface::init");
129  info(" Device Description -> "+m_deviceDesc,"UsbFTInterface::init");
130  info(" Serial Number -> "+m_serialNum,"UsbFTInterface::init");
131  }
132 */
133  }
134  wait(1000);
135  return StatusCode::SUCCESS;
136 }
void info(std::string mymsg)
Definition: Object.h:38
std::string itos(int)
Definition: Tools.cpp:46
LALUSB_API BOOL _cstmcall USB_GetLatencyTimer(int id, PUCHAR msecs)
LALUSB_API void _cstmcall USB_Perror(USB_Error err_code)
LALUSB_API BOOL _cstmcall USB_SetLatencyTimer(int id, UCHAR msecs)
void fatal(std::string mymsg)
Definition: Object.h:41
LALUSB_API int _cstmcall OpenUsbDevice(char *sernumstr)
LALUSB_API FT_STATUS _cstmcall GetDeviceSerNum(char *buffer, int index)
Definition: ftd2xx.h:80
void error(std::string mymsg)
Definition: Object.h:40
std::string m_deviceDesc
std::string m_serialNum
LALUSB_API BOOL _cstmcall USB_SetTimeouts(int id, int tx_timeout, int rx_timeout)
LALUSB_API BOOL _cstmcall USB_FindDevices(char *DeviceDescriptionStr)
LALUSB_API BOOL _cstmcall USB_Init(int id, BOOL verbose)
unsigned char m_latencyTimer
std::string name() const
Definition: Object.h:28
LALUSB_API FT_STATUS _cstmcall GetDeviceDesc(char *buffer, int index)
LALUSB_API void _cstmcall UsbSetIntCheckingState(BOOL truefalse)
void wait(int nbr_ms)
Definition: Tools.cpp:271
LALUSB_API BOOL _cstmcall USB_SetXferSize(int id, unsigned long txsize, unsigned long rxsize)
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)

◆ interrupts()

bool UsbFTInterface::interrupts ( )
inline

Get accessor to member m_interrupts

Returns
the current value of m_interrupts

Definition at line 425 of file UsbFTInterface.h.

References m_interrupts.

Referenced by setInterrupts().

425  {
426  return m_interrupts;
427  }

◆ latencyTimer()

unsigned char UsbFTInterface::latencyTimer ( )
inline

Get accessor to member m_latTimer

Returns
the current value of m_latTimer

Definition at line 289 of file UsbFTInterface.h.

References m_latencyTimer, m_usbId, and USB_GetLatencyTimer().

Referenced by BOOST_PYTHON_MODULE(), and setLatencyTimer().

289  {
291  return m_latencyTimer;
292  }
LALUSB_API BOOL _cstmcall USB_GetLatencyTimer(int id, PUCHAR msecs)
unsigned char m_latencyTimer

◆ nFrames()

long int UsbFTInterface::nFrames ( )
inline

Get accessor to member m_nFrames

Returns
the current value of m_nFrames

Definition at line 360 of file UsbFTInterface.h.

References m_nFrames.

Referenced by setNFrames().

360  {
361  return m_nFrames;
362  }
long int m_nFrames

◆ printout()

bool UsbFTInterface::printout ( )
inline

Get accessor to member m_printout

Returns
the current value of m_printout

Definition at line 489 of file UsbFTInterface.h.

References m_printout.

Referenced by setPrintout().

489  {
490  return m_printout;
491  }

◆ rdBlockMax()

bool UsbFTInterface::rdBlockMax ( )
inline

Get accessor to member m_rdBlockMax

Returns
the current value of m_rdBlockMax

Definition at line 465 of file UsbFTInterface.h.

References m_rdBlockMax.

Referenced by setRdBlockMax().

465  {
466  return m_rdBlockMax;
467  }

◆ read() [1/2]

StatusCode UsbFTInterface::read ( IOdata io)
virtual

Implements Interface.

Definition at line 817 of file UsbFTInterface.cpp.

References IOdata::address(), IOdata::Byte, shell::data(), IOdata::dataU16(), IOdata::dataU32(), IOdata::dataU8(), IOdata::DWord, Object::error(), StatusCode::FAILURE, itos(), IOdata::length(), m_rdBlockMax, usbReadU16(), usbReadU32(), usbReadU8(), Object::verbose(), IOdata::Word, and IOdata::wordSize().

Referenced by BOOST_PYTHON_MODULE(), and update().

817  {
818  unsigned long int address = io->address();
819  unsigned long int nWords = io->length();
820  StatusCode status;
821  switch (io->wordSize())
822  {
823  case (IOdata::Byte):
824  if (nWords<m_rdBlockMax+1){
825  verbose("Reading a single block "+itos(nWords)+"/"+itos(m_rdBlockMax),
826  "UsbFTInterface::read");
827  status = usbReadU8( address, nWords, io->dataU8());
828  }
829  else {
830  // int nwords=nWords;
831  U8* data=io->dataU8();
832  int nXfer=(int)(nWords/m_rdBlockMax)+1;
833  for (int i=0; i<nXfer ; ++i){
834  if (i<nXfer-1){
835  verbose("Reading block "+itos(i)+
836  " of size "+itos(m_rdBlockMax),
837  "UsbFTInterface::read");
838  status = usbReadU8( address,
839  m_rdBlockMax ,
840  data);
841  data+=sizeof(U8*)*m_rdBlockMax;
842  }
843  else {
844  verbose("Reading last block "+itos(i)+
845  " of size "+itos(nWords%m_rdBlockMax),
846  "UsbFTInterface::read");
847  status = usbReadU8( address,
848  nWords%m_rdBlockMax ,
849  data);
850  data+=sizeof(U8*)*(nWords%m_rdBlockMax);
851  }
852  }
853  }
854  break;
855  case (IOdata::Word):
856  status = usbReadU16( address, nWords, io->dataU16());
857  break;
858  case (IOdata::DWord):
859  status = usbReadU32( address, nWords, io->dataU32());
860  break;
861  default:
862  error("Wrong word size.","UsbFTInterface::read");
863  status=StatusCode::FAILURE;
864  }
865  return status;
866 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
StatusCode usbReadU8(unsigned long int, unsigned long int, unsigned char *)
U32 address()
Definition: IOdata.h:59
U32 * dataU32()
Definition: IOdata.h:222
unsigned char U8
Definition: ICECALv3.h:55
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
U32 length()
Definition: IOdata.h:175
U16 * dataU16()
Definition: IOdata.h:218
U8 * dataU8()
Definition: IOdata.h:214
IOdata::WordSize wordSize()
Definition: IOdata.h:133
StatusCode usbReadU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbReadU32(unsigned long int, unsigned long int, unsigned long *)

◆ read() [2/2]

StatusCode UsbFTInterface::read ( unsigned long int  address,
unsigned long int  nWords,
boost::python::list &  obj 
)

Python interpreter wrapping for usb read

Definition at line 142 of file UsbFTInterface.cpp.

References shell::data(), Object::error(), StatusCode::FAILURE, itos(), m_wordSize, usbReadU16(), usbReadU32(), usbReadU8(), Object::verbose(), WS_Byte, WS_DWord, and WS_Word.

145 {
146  StatusCode status;
147  verbose("USB Reading :","UsbFTInterface::read");
148  switch (m_wordSize)
149  {
150  case WS_Byte:
151  {
152  unsigned char *data=new unsigned char[nWords];
153  status = usbReadU8( address, nWords, data);
154  verbose("Data format is "+itos(WS_Byte),"UsbFTInterface::read");
155  for(unsigned int i = 0; i < nWords; i++){
156  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::read");
157  obj.append(data[i]);
158  };
159  delete data;
160  }
161  break;
162  case WS_Word:
163  {
164  unsigned short *data=new unsigned short[nWords];
165  status = usbReadU16( address, nWords, data);
166  verbose("Data format is "+itos(WS_Word),"UsbFTInterface::read");
167  for(unsigned int i = 0; i < nWords; i++){
168  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::read");
169  obj.append(data[i]);
170  };
171  delete data;
172  }
173  break;
174  case WS_DWord:
175  {
176  unsigned long *data=new unsigned long[nWords];
177  status = usbReadU32( address, nWords, data);
178  verbose("Data format is "+itos(WS_DWord),"UsbFTInterface::read");
179  for(unsigned int i = 0; i < nWords; i++){
180  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::read");
181  obj.append(data[i]);
182  };
183  delete data;
184  }
185  break;
186  default:
187  error("Wrong word size.","UsbFTInterface::read");
188  status=StatusCode::FAILURE;
189  }
190  return status;
191 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
StatusCode usbReadU8(unsigned long int, unsigned long int, unsigned char *)
unsigned long m_wordSize
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
StatusCode usbReadU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbReadU32(unsigned long int, unsigned long int, unsigned long *)
def obj()
Definition: shell.py:26

◆ reset()

virtual void UsbFTInterface::reset ( )
inlinevirtual

Resets the Element so that is is in a standard and safe situation. Different from Element::init which configure the Element. Element::reset() is more an Emergency pull. It is often/usually called by the recursiveInitElement method at the start of the program.

Implements Interface.

Definition at line 91 of file UsbFTInterface.h.

References close(), Object::info(), init(), and Object::name().

91  {
92  // USB_ResetDevice(m_usbId);
93  info("Reset of the Usb interface "+name(),"UsbFTInterface::reset");
94  close();
95  init();
96  };
void info(std::string mymsg)
Definition: Object.h:38
std::string name() const
Definition: Object.h:28
virtual StatusCode init()

◆ rxBuffer()

int UsbFTInterface::rxBuffer ( )
inline

Get accessor to member m_rxBuffer

Returns
the current value of m_rxBuffer

Definition at line 344 of file UsbFTInterface.h.

References m_rxBuffer.

Referenced by BOOST_PYTHON_MODULE(), and setBuffer().

344  {
345  return m_rxBuffer;
346  }

◆ rxTimeOut()

int UsbFTInterface::rxTimeOut ( )
inline

Get accessor to member m_rxTimeOut

Returns
the current value of m_rxTimeOut

Definition at line 317 of file UsbFTInterface.h.

References m_rxTimeOut.

Referenced by BOOST_PYTHON_MODULE(), and setTimeOut().

317  {
318  // USB_SetTimeouts(m_usbId,&m_txTimeOut,&m_rxTimeOut)
319  return m_rxTimeOut;
320  }

◆ serialNum()

std::string UsbFTInterface::serialNum ( )
inline

Get accessor to member m_serialNum

Returns
the current value of m_serialNum

Definition at line 256 of file UsbFTInterface.h.

References m_serialNum.

Referenced by BOOST_PYTHON_MODULE(), and setSerialNum().

256  {
257  return m_serialNum;
258  }
std::string m_serialNum

◆ setBuffer()

void UsbFTInterface::setBuffer ( int  txBuffer,
int  rxBuffer 
)
inline

Set accessor to member m_txBuffer

Parameters
txBufferthe new value for m_txBuffer

Definition at line 326 of file UsbFTInterface.h.

References m_rxBuffer, m_txBuffer, m_usbId, rxBuffer(), txBuffer(), and USB_SetXferSize().

Referenced by BOOST_PYTHON_MODULE().

326  {
330  }
LALUSB_API BOOL _cstmcall USB_SetXferSize(int id, unsigned long txsize, unsigned long rxsize)

◆ setDeviceDesc()

void UsbFTInterface::setDeviceDesc ( std::string  deviceDesc)
inline

Set accessor to member m_deviceDesc

Parameters
deviceDescthe new value for m_deviceDesc

Definition at line 264 of file UsbFTInterface.h.

References deviceDesc(), and m_deviceDesc.

Referenced by BOOST_PYTHON_MODULE().

264  {
266  }
std::string deviceDesc()
std::string m_deviceDesc

◆ setFakeErr()

void UsbFTInterface::setFakeErr ( unsigned int  fakeErr)
inline

Set accessor to member m_fakeErr

Parameters
fakeErrthe new value for m_fakeErr

Definition at line 401 of file UsbFTInterface.h.

References fakeErr(), and m_fakeErr.

401  {
402  m_fakeErr = fakeErr;
403  }
unsigned int fakeErr()
unsigned int m_fakeErr

◆ setInterrupts()

void UsbFTInterface::setInterrupts ( bool  interrupts)
inline

Set accessor to member m_interrupts

Parameters
interruptsthe new value for m_interrupts

Definition at line 417 of file UsbFTInterface.h.

References interrupts(), and m_interrupts.

417  {
419  }

◆ setLatencyTimer()

void UsbFTInterface::setLatencyTimer ( unsigned char  latencyTimer)
inline

Set accessor to member m_latencyTimer

Parameters
latTimerthe new value for m_latencyTimer

Definition at line 280 of file UsbFTInterface.h.

References latencyTimer(), m_latencyTimer, m_usbId, and USB_SetLatencyTimer().

Referenced by BOOST_PYTHON_MODULE().

280  {
283  }
LALUSB_API BOOL _cstmcall USB_SetLatencyTimer(int id, UCHAR msecs)
unsigned char m_latencyTimer
unsigned char latencyTimer()

◆ setNFrames()

void UsbFTInterface::setNFrames ( long int  nFrames)
inline

Set accessor to member m_nFrames

Parameters
nFramesthe new value for m_nFrames

Definition at line 352 of file UsbFTInterface.h.

References m_nFrames, and nFrames().

352  {
353  m_nFrames = nFrames;
354  }
long int m_nFrames
long int nFrames()

◆ setPrintout()

void UsbFTInterface::setPrintout ( bool  printout)
inline

Set accessor to member m_printout

Parameters
printoutthe new value for m_printout

Definition at line 481 of file UsbFTInterface.h.

References m_printout, and printout().

481  {
483  }

◆ setRdBlockMax()

void UsbFTInterface::setRdBlockMax ( bool  rdBlockMax)
inline

Set accessor to member m_rdBlockMax

Parameters
rdBlockMaxthe new value for m_rdBlockMax

Definition at line 473 of file UsbFTInterface.h.

References m_rdBlockMax, and rdBlockMax().

473  {
475  }

◆ setSerialNum()

void UsbFTInterface::setSerialNum ( std::string  serialNum)
inline

Set accessor to member m_serialNum

Parameters
serialNumthe new value for m_serialNum

Definition at line 248 of file UsbFTInterface.h.

References m_serialNum, and serialNum().

Referenced by BOOST_PYTHON_MODULE().

248  {
250  }
std::string serialNum()
std::string m_serialNum

◆ setShowEpromState()

void UsbFTInterface::setShowEpromState ( bool  showEpromState)
inline

Set accessor to member m_showEpromState

Parameters
showEpromStatethe new value for m_showEpromState

Definition at line 433 of file UsbFTInterface.h.

References m_showEpromState, and showEpromState().

433  {
435  }

◆ setTimeOut()

void UsbFTInterface::setTimeOut ( int  txTimeOut,
int  rxTimeOut 
)
inline

Set accessor to member m_txTimeOut

Parameters
txTimeOutthe new value for m_txTimeOut

Definition at line 298 of file UsbFTInterface.h.

References m_rxTimeOut, m_txTimeOut, m_usbId, rxTimeOut(), txTimeOut(), and USB_SetTimeouts().

Referenced by BOOST_PYTHON_MODULE().

298  {
302  }
LALUSB_API BOOL _cstmcall USB_SetTimeouts(int id, int tx_timeout, int rx_timeout)

◆ setUsbId()

void UsbFTInterface::setUsbId ( int  usbId)
inline

Set accessor to member m_usbId

Parameters
usbIdthe new value for m_usbId

Definition at line 232 of file UsbFTInterface.h.

References m_usbId, and usbId().

232  {
233  m_usbId = usbId;
234  }

◆ setWordCount()

void UsbFTInterface::setWordCount ( unsigned long  wordCount)
inline

Set accessor to member m_wordCount

Parameters
wordCountthe new value for m_wordCount

Definition at line 369 of file UsbFTInterface.h.

References m_wordCount, and wordCount().

369  {
371  }
unsigned long wordCount()
unsigned long m_wordCount

◆ setWordSize()

void UsbFTInterface::setWordSize ( unsigned long  wordSize)
inline

Set accessor to member m_wordSize

Parameters
wordSizethe new value for m_wordSize

Definition at line 385 of file UsbFTInterface.h.

References m_wordSize, and wordSize().

Referenced by BOOST_PYTHON_MODULE(), and UsbFTInterfaceTest::execute().

385  {
387  }
unsigned long wordSize()
unsigned long m_wordSize

◆ setWrBlockMax()

void UsbFTInterface::setWrBlockMax ( bool  wrBlockMax)
inline

Set accessor to member m_wrBlockMax

Parameters
wrBlockMaxthe new value for m_wrBlockMax

Definition at line 457 of file UsbFTInterface.h.

References m_wrBlockMax, and wrBlockMax().

457  {
459  }

◆ showEpromState()

bool UsbFTInterface::showEpromState ( )
inline

Get accessor to member m_showEpromState

Returns
the current value of m_showEpromState

Definition at line 441 of file UsbFTInterface.h.

References m_showEpromState.

Referenced by setShowEpromState().

441  {
442  return m_showEpromState;
443  }

◆ txBuffer()

int UsbFTInterface::txBuffer ( )
inline

Get accessor to member m_txBuffer

Returns
the current value of m_txBuffer

Definition at line 336 of file UsbFTInterface.h.

References m_txBuffer.

Referenced by BOOST_PYTHON_MODULE(), and setBuffer().

336  {
337  return m_txBuffer;
338  }

◆ txTimeOut()

int UsbFTInterface::txTimeOut ( )
inline

Get accessor to member m_txTimeOut

Returns
the current value of m_txTimeOut

Definition at line 308 of file UsbFTInterface.h.

References m_txTimeOut.

Referenced by BOOST_PYTHON_MODULE(), and setTimeOut().

308  {
309  // USB_SetTimeouts(m_usbId,&m_txTimeOut,&m_rxTimeOut)
310  return m_txTimeOut;
311  }

◆ update()

virtual void UsbFTInterface::update ( )
inlinevirtual

◆ usbId()

int UsbFTInterface::usbId ( )
inline

Get accessor to member m_usbId

Returns
the current value of m_usbId

Definition at line 240 of file UsbFTInterface.h.

References m_usbId.

Referenced by setUsbId().

240  {
241  return m_usbId;
242  }

◆ usbRead()

StatusCode UsbFTInterface::usbRead ( unsigned long int  address,
unsigned long int  nWords,
std::vector< U32 > &  words 
)

Read usb in std::vector format – Do not use : Only supports U8 ! Write usb in std::vector<U8> format – Do not use yet : Only supports U8 ! Read usb in std::vector format – Do not use : Only supports U8 ! Write usb in std::vector<U16> format – Do not use yet : Only supports U8 ! Read usb in std::vector format – Do not use : Only supports U8 !

Definition at line 250 of file UsbFTInterface.cpp.

References shell::data(), Object::error(), StatusCode::FAILURE, itos(), m_wordSize, usbReadU16(), usbReadU32(), usbReadU8(), Object::verbose(), WS_Byte, WS_DWord, and WS_Word.

Referenced by UsbFTInterfaceTest::execute(), and update().

253 {
254  StatusCode status;
255  verbose("USB Reading :","UsbFTInterface::read");
256  words.clear();
257  words.reserve(nWords);
258  switch (m_wordSize)
259  {
260  case WS_Byte:
261  {
262  unsigned char *data=new unsigned char[nWords];
263  status = usbReadU8( address, nWords, data);
264  for(unsigned int i = 0; i < nWords; i++){
265  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::usbRead");
266  words.push_back(data[i]);
267  };
268  delete data;
269  }
270  break;
271  case WS_Word:
272  {
273  unsigned short *data=new unsigned short[nWords];
274  status = usbReadU16( address, nWords, data);
275  for(unsigned int i = 0; i < nWords; i++){
276  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::usbRead");
277  words.push_back(data[i]);
278  };
279  delete data;
280  }
281  break;
282  case WS_DWord:
283  {
284  unsigned long *data=new unsigned long[nWords];
285  status = usbReadU32( address, nWords, data);
286  for(unsigned int i = 0; i < nWords; i++){
287  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::usbRead");
288  words.push_back(data[i]);
289  };
290  delete data;
291  }
292  break;
293  default:
294  error("Wrong word size.","UsbFTInterface::read");
295  status=StatusCode::FAILURE;
296  }
297  return status;
298 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
StatusCode usbReadU8(unsigned long int, unsigned long int, unsigned char *)
unsigned long m_wordSize
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
StatusCode usbReadU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbReadU32(unsigned long int, unsigned long int, unsigned long *)

◆ usbReadU16()

StatusCode UsbFTInterface::usbReadU16 ( unsigned long int  address,
unsigned long int  nWords,
unsigned short *  data 
)

Definition at line 482 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbRd(), and Object::verbose().

Referenced by read(), update(), and usbRead().

484  {
485 
486  USB_Error rdErr=USB_NoErr;
487  long int bytecount=0;
488 
489  verbose("in UsbReadU16.");
490 
491 
492  long int nData = (long int)(2*nWords);
493 
494  unsigned char *buff=new unsigned char [nData];
495 
496 
497  verbose("before usbread");
498  bytecount=UsbRd(m_usbId, address, buff, nData);
499  verbose("after usbread");
500 
501  for (unsigned long word=0; word<nWords; ++word)
502  {
503  data[word]=buff[2*word+1];
504  data[word]=(data[word]<<8)|buff[2*word];
505  }
506 
507  delete buff;
508 
509  if (nData==bytecount){
510  verbose(itos(bytecount)+" bytes read from USB Interface "+name(),
511  "UsbFTInterface::usbReadU16");
512  return StatusCode::SUCCESS;
513  }
514 
515  if (bytecount<0){
516  rdErr=USB_GetLastError();
517  error("USB error number "+itos(rdErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
518  " UsbFTInterface::usbReadU16");
519  if (rdErr==USB_INT_FRAME){
520  PrintFrameInfo();
521  }
522  return StatusCode::FAILURE;
523  }
524 
525  if (0==bytecount){
526  error(" O Byte read from USB interface "+name()+".",
527  "UsbFTInterface::usbReadU16");
528  return StatusCode::FAILURE;
529  }
530 
531  if (nData!=bytecount){
532  error(itos(bytecount)+" byte(s) read from USB interface "+name()+
533  " out of "+itos(nData)+" bytes expected.",
534  "UsbFTInterface::usbReadU16");
535  return StatusCode::FAILURE;
536  }
537 
538  return StatusCode::SUCCESS;
539 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
LALUSB_API int _cstmcall UsbRd(int id, char sub_addr, void *array, int count)
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbReadU32()

StatusCode UsbFTInterface::usbReadU32 ( unsigned long int  address,
unsigned long int  nWords,
unsigned long *  data 
)

Definition at line 544 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbRd(), and Object::verbose().

Referenced by read(), update(), and usbRead().

546  {
547 
548  USB_Error rdErr=USB_NoErr;
549  long int bytecount=0;
550 
551  long int nData = (long int)(4*nWords);
552 
553  unsigned char *buff=new unsigned char [nData];
554 
555  bytecount=UsbRd(m_usbId, address, buff, nData);
556 
557  for (unsigned long word=0; word<nWords; ++word)
558  {
559  data[word]=buff[4*word+3];
560  data[word]=(data[word]<<8)|buff[4*word+2];
561  data[word]=(data[word]<<8)|buff[4*word+1];
562  data[word]=(data[word]<<8)|buff[4*word];
563  }
564 
565  delete buff;
566 
567  if (nData==bytecount){
568  verbose(itos(bytecount)+" bytes read from USB Interface "+name(),
569  "UsbFTInterface::usbRead");
570  return StatusCode::SUCCESS;
571  }
572 
573  if (bytecount<0){
574  rdErr=USB_GetLastError();
575  error("USB error number "+itos(rdErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
576  " UsbFTInterface::usbRead32");
577  if (rdErr==USB_INT_FRAME){
578  PrintFrameInfo();
579  }
580  return StatusCode::FAILURE;
581  }
582 
583  if (0==bytecount){
584  error(" O Byte read from USB interface "+name()+".","UsbFTInterface::usbRead32");
585  return StatusCode::FAILURE;
586  }
587 
588  if (nData!=bytecount){
589  error(itos(bytecount)+" byte(s) read from USB interface "+name()+
590  " out of "+itos(nData)+" bytes expected.","UsbFTInterface::usbRead32");
591  return StatusCode::FAILURE;
592  }
593  return StatusCode::SUCCESS;
594 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
LALUSB_API int _cstmcall UsbRd(int id, char sub_addr, void *array, int count)
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbReadU8()

StatusCode UsbFTInterface::usbReadU8 ( unsigned long int  address,
unsigned long int  nWords,
unsigned char *  data 
)

Read usb (U8 format)

Definition at line 438 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbRd(), and Object::verbose().

Referenced by read(), update(), and usbRead().

440  {
441 
442  USB_Error rdErr=USB_NoErr;
443  long int bytecount=0;
444 
445  long int nData = (long int)(nWords);
446 
447  bytecount=UsbRd(m_usbId, address, data, nData);
448 
449  if (nData==bytecount){
450  verbose(itos(bytecount)+" bytes read from USB Interface "+name(),
451  "UsbFTInterface::usbRead8");
452  return StatusCode::SUCCESS;
453  }
454 
455  if (bytecount<0){
456  rdErr=USB_GetLastError();
457  error("USB error number "+itos(rdErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
458  " UsbFTInterface::usbRead8");
459  if (rdErr==USB_INT_FRAME){
460  PrintFrameInfo();
461  }
462  return StatusCode::FAILURE;
463  }
464 
465  if (0==bytecount){
466  error(" O Byte read from USB interface "+name()+".","UsbFTInterface::usbRead8");
467  return StatusCode::FAILURE;
468  }
469 
470  if (nData!=bytecount){
471  error(itos(bytecount)+" byte(s) read from USB interface "+name()+
472  " out of "+itos(nData)+" bytes expected.","UsbFTInterface::usbRead8");
473  return StatusCode::FAILURE;
474  }
475 
476  return StatusCode::SUCCESS;
477 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
LALUSB_API int _cstmcall UsbRd(int id, char sub_addr, void *array, int count)
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbWrite()

StatusCode UsbFTInterface::usbWrite ( unsigned long int  address,
std::vector< U32 words 
)

Write usb in std::vector<U32> format – Do not use yet : Only supports U8 !

Definition at line 303 of file UsbFTInterface.cpp.

References shell::data(), Object::error(), StatusCode::FAILURE, itos(), m_wordSize, usbWriteU16(), usbWriteU32(), usbWriteU8(), Object::verbose(), WS_Byte, WS_DWord, and WS_Word.

Referenced by UsbFTInterfaceTest::execute(), and update().

305 {
306  unsigned long int nWords = words.size();
307  StatusCode status;
308  verbose("USB Writing :");
309  switch (m_wordSize)
310  {
311  case WS_Byte:
312  {
313  unsigned char *data=new unsigned char[nWords];
314  for(unsigned int i = 0; i < nWords; i++){
315  data[i]=words[i];
316  verbose("Data format is "+itos(WS_Byte),"UsbFTInterface::usbWrite");
317  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::usbWrite");
318  };
319  status = usbWriteU8(address, nWords, data);
320  delete data;
321  }
322  break;
323  case WS_Word:
324  {
325  unsigned short *data=new unsigned short[nWords];
326  for(unsigned int i = 0; i < nWords; i++){
327  data[i]=words[i];
328  verbose("Data format is "+itos(WS_Word),"UsbFTInterface::usbWrite");
329  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::usbWrite");
330  };
331  status = usbWriteU16(address, nWords, data);
332  delete data;
333  }
334  break;
335  case WS_DWord:
336  {
337  unsigned long *data=new unsigned long[nWords];
338  for(unsigned int i = 0; i < nWords; i++){
339  data[i]=words[i];
340  verbose("Data format is "+itos(WS_DWord),"UsbFTInterface::usbWrite");
341  verbose("wd "+itos(i)+" "+itos(data[i]) ,"UsbFTInterface::usbWrite");
342  }
343  status = usbWriteU32(address, nWords, data);
344  delete data;
345  }
346  break;
347  default:
348  error("Wrong word size.","read");
349  status=StatusCode::FAILURE;
350  }
351  return status;
352 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
unsigned long m_wordSize
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
StatusCode usbWriteU32(unsigned long int, unsigned long int, unsigned long *)
StatusCode usbWriteU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbWriteU8(unsigned long int, unsigned long int, unsigned char *)

◆ usbWriteRead()

StatusCode UsbFTInterface::usbWriteRead ( unsigned long int  address,
std::vector< U8 dataWrite,
std::vector< U8 > &  dataRead 
)

Write/Read std::vector<U8> format – Do not use yet : Only supports U8 !

Definition at line 725 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbRd(), UsbWrt(), and Object::verbose().

Referenced by update().

727  {
728  USB_Error rdErr=USB_NoErr, wrErr=USB_NoErr;
729  long int bytecount=0;
730  long int nData=dataWrite.size();
731  const unsigned long int bufSize=nData+4;
732  U8* bufWr=new U8[bufSize];
733  U8* bufRd=new U8[bufSize];
734 
735  for(int j=0; j<nData; ++j) bufWr[j] = static_cast<unsigned char>(dataWrite[j]);
736 
737  bytecount=UsbWrt(m_usbId, address, bufWr, nData);
738 
739  if (bytecount<0){
740  wrErr=USB_GetLastError();
741  error("USB error number "+itos(wrErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
742  " UsbFTInterface::usbWriteRead");
743  if (wrErr==USB_INT_FRAME){
744  PrintFrameInfo();
745  }
746  return StatusCode::FAILURE;
747  }
748 
749  if (nData==bytecount){
750  verbose(itos(bytecount)+" bytes written on USB Interface "+name(),
751  "UsbFTInterface::usbWriteRead");
752 
753  bytecount=UsbRd(m_usbId, address, bufRd, nData);
754 
755  if (nData==bytecount){
756  verbose(itos(bytecount)+" bytes read from USB Interface "+name(),
757  "UsbFTInterface::usbRead");
758  for(int j=0; j<nData; ++j) dataRead[j] = static_cast<unsigned char>(bufRd[j]);
759  return StatusCode::SUCCESS;
760  }
761 
762  if (bytecount<0){
763  rdErr=USB_GetLastError();
764  error("USB error number "+itos(rdErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
765  " UsbFTInterface::usbWriteRead");
766  if (rdErr==USB_INT_FRAME){
767  PrintFrameInfo();
768  }
769  return StatusCode::FAILURE;
770  }
771 
772  if (0==bytecount){
773  error(" O Byte read from USB interface "+name()+".","UsbFTInterface::usbRead");
774  return StatusCode::FAILURE;
775  }
776 
777  if (nData!=bytecount){
778  error(itos(bytecount)+" byte(s) read from USB interface "+name()+
779  " out of "+itos(nData)+" bytes expected.","UsbFTInterface::usbRead");
780  return StatusCode::FAILURE;
781  }
782  }
783 
784 
785  if (0==bytecount){
786  error(" O Byte written n USB interface "+name()+".","UsbFTInterface::usbWrite");
787  return StatusCode::FAILURE;
788  }
789 
790  if (nData!=bytecount){
791  error(itos(bytecount)+" byte(s) written USB interface "+name()+
792  " out of "+itos(nData)+" bytes to be sent.","UsbFTInterface::usbWrite");
793  return StatusCode::FAILURE;
794  }
795 
797 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
LALUSB_API int _cstmcall UsbRd(int id, char sub_addr, void *array, int count)
FT_STATUS USB_Error
Definition: LALUsbML.h:72
unsigned char U8
Definition: ICECALv3.h:55
void error(std::string mymsg)
Definition: Object.h:40
std::string name() const
Definition: Object.h:28
LALUSB_API int _cstmcall UsbWrt(int id, char sub_addr, void *buffer, int count)
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbWriteU16()

StatusCode UsbFTInterface::usbWriteU16 ( unsigned long int  address,
unsigned long int  nWords,
unsigned short *  data 
)

Write usb (U16 format)

Definition at line 641 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbWrt(), and Object::verbose().

Referenced by update(), usbWrite(), and write().

643  {
644  USB_Error wrErr=USB_NoErr;
645  long int bytecount=0;
646 
647  long int nData=(long int)(2*nWords);
648 
649  bytecount=UsbWrt(m_usbId, address, data, nData);
650 
651  if (bytecount<0){
652  wrErr=USB_GetLastError();
653  error("USB error number "+itos(wrErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
654  "UsbFTInterface::usbWrite16");
655  if (wrErr==USB_INT_FRAME){
656  PrintFrameInfo();
657  }
658  return StatusCode::FAILURE;
659  }
660 
661  if (nData==bytecount){
662  verbose(itos(bytecount)+" bytes written on USB Interface "+name(),
663  "UsbFTInterface::usbWrite16");
664  }
665 
666  if (0==bytecount){
667  error(" O Byte written on USB interface "+name()+".","UsbFTInterface::usbWrite16");
668  return StatusCode::FAILURE;
669  }
670 
671  if (nData!=bytecount){
672  error(itos(bytecount)+" byte(s) written on USB interface "+name()+
673  " out of "+itos(nData)+" bytes to be sent.","UsbFTInterface::usbWrite16");
674  return StatusCode::FAILURE;
675  }
676 
677  return StatusCode::SUCCESS;
678 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API int _cstmcall UsbWrt(int id, char sub_addr, void *buffer, int count)
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbWriteU32()

StatusCode UsbFTInterface::usbWriteU32 ( unsigned long int  address,
unsigned long int  nWords,
unsigned long *  data 
)

Write usb (U32 format)

Definition at line 683 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbWrt(), and Object::verbose().

Referenced by update(), usbWrite(), and write().

685  {
686  USB_Error wrErr=USB_NoErr;
687  long int bytecount=0;
688 
689  long int nData=(long int)(4*nWords);
690 
691  bytecount=UsbWrt(m_usbId, address, data, nData);
692 
693  if (bytecount<0){
694  wrErr=USB_GetLastError();
695  error("USB error number "+itos(wrErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
696  "UsbFTInterface::usbWrite32");
697  if (wrErr==USB_INT_FRAME){
698  PrintFrameInfo();
699  }
700  return StatusCode::FAILURE;
701  }
702 
703  if (nData==bytecount){
704  verbose(itos(bytecount)+" bytes written on USB Interface "+name(),
705  "UsbFTInterface::usbWrite32");
706  }
707 
708  if (0==bytecount){
709  error(" O Byte written on USB interface "+name()+".","UsbFTInterface::usbWrite32");
710  return StatusCode::FAILURE;
711  }
712 
713  if (nData!=bytecount){
714  error(itos(bytecount)+" byte(s) written on USB interface "+name()+
715  " out of "+itos(nData)+" bytes to be sent.","UsbFTInterface::usbWrite32");
716  return StatusCode::FAILURE;
717  }
718 
719  return StatusCode::SUCCESS;
720 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API int _cstmcall UsbWrt(int id, char sub_addr, void *buffer, int count)
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ usbWriteU8()

StatusCode UsbFTInterface::usbWriteU8 ( unsigned long int  address,
unsigned long int  nWords,
unsigned char *  data 
)

Write usb (U8 format)

Definition at line 599 of file UsbFTInterface.cpp.

References Object::error(), StatusCode::FAILURE, itos(), m_usbId, Object::name(), PrintFrameInfo(), StatusCode::SUCCESS, USB_GetLastError(), USB_INT_FRAME, USB_NoErr, UsbWrt(), and Object::verbose().

Referenced by update(), usbWrite(), and write().

601  {
602  USB_Error wrErr=USB_NoErr;
603  long int bytecount=0;
604 
605  long int nData=(long int)(nWords);
606 
607  bytecount=UsbWrt(m_usbId, address, data, nData);
608 
609  if (bytecount<0){
610  wrErr=USB_GetLastError();
611  error("USB error number "+itos(wrErr)+" - USB_INT_FRAME="+itos(USB_INT_FRAME),
612  "UsbFTInterface::usbWrite8");
613  if (wrErr==USB_INT_FRAME){
614  PrintFrameInfo();
615  }
616  return StatusCode::FAILURE;
617  }
618 
619  if (nData==bytecount){
620  verbose(itos(bytecount)+" bytes written on USB Interface "+name(),
621  "UsbFTInterface::usbWrite8");
622  }
623 
624  if (0==bytecount){
625  error(" O Byte written on USB interface "+name()+".","UsbFTInterface::usbWrite8");
626  return StatusCode::FAILURE;
627  }
628 
629  if (nData!=bytecount){
630  error(itos(bytecount)+" byte(s) written on USB interface "+name()+
631  " out of "+itos(nData)+" bytes to be sent.","UsbFTInterface::usbWrite8");
632  return StatusCode::FAILURE;
633  }
634 
635  return StatusCode::SUCCESS;
636 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
#define USB_NoErr
Definition: LALUsbML.h:69
FT_STATUS USB_Error
Definition: LALUsbML.h:72
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
std::string name() const
Definition: Object.h:28
LALUSB_API int _cstmcall UsbWrt(int id, char sub_addr, void *buffer, int count)
LALUSB_API USB_Error _cstmcall USB_GetLastError(void)
LALUSB_API void _cstmcall PrintFrameInfo(void)

◆ wordCount()

unsigned long UsbFTInterface::wordCount ( )
inline

Get accessor to member m_wordCount

Returns
the current value of m_wordCount

Definition at line 377 of file UsbFTInterface.h.

References m_wordCount.

Referenced by setWordCount().

377  {
378  return m_wordCount;
379  }
unsigned long m_wordCount

◆ wordSize()

unsigned long UsbFTInterface::wordSize ( )
inline

Get accessor to member m_wordSize

Returns
the current value of m_wordSize

Definition at line 393 of file UsbFTInterface.h.

References m_wordSize.

Referenced by BOOST_PYTHON_MODULE(), and setWordSize().

393  {
394  return m_wordSize;
395  }
unsigned long m_wordSize

◆ wrBlockMax()

bool UsbFTInterface::wrBlockMax ( )
inline

Get accessor to member m_wrBlockMax

Returns
the current value of m_wrBlockMax

Definition at line 449 of file UsbFTInterface.h.

References m_wrBlockMax.

Referenced by setWrBlockMax().

449  {
450  return m_wrBlockMax;
451  }

◆ write() [1/2]

StatusCode UsbFTInterface::write ( IOdata io)
virtual

Implements Interface.

Definition at line 871 of file UsbFTInterface.cpp.

References IOdata::address(), IOdata::Byte, shell::data(), IOdata::dataU16(), IOdata::dataU32(), IOdata::dataU8(), IOdata::DWord, Object::error(), StatusCode::FAILURE, itos(), IOdata::length(), m_wrBlockMax, usbWriteU16(), usbWriteU32(), usbWriteU8(), Object::verbose(), IOdata::Word, and IOdata::wordSize().

Referenced by BOOST_PYTHON_MODULE(), and update().

871  {
872  unsigned long int address = io->address();
873  unsigned long int nWords = io->length();
874  StatusCode status;
875  switch (io->wordSize())
876  {
877  case (IOdata::Byte):
878  if (nWords<m_wrBlockMax+1){
879  verbose("Writing a single block "+itos(nWords)+"/"+itos(m_wrBlockMax),
880  "UsbFTInterface::write");
881  status = usbWriteU8(address, nWords, io->dataU8());
882  }
883  else {
884  // int nwords=nWords;
885  U8* data=io->dataU8();
886  int nXfer=(int)ceil((float)(nWords)/(float)(m_wrBlockMax));
887  verbose("number of Xfer="+itos(nXfer)+
888  " "+itos(m_wrBlockMax)+
889  " "+itos(nWords),"");
890  for (int i=0; i<nXfer ; ++i){
891  if (i<nXfer-1){
892  verbose("Writing block "+itos(i)+
893  " of size "+itos(m_wrBlockMax),
894  "UsbFTInterface::write");
895  status = usbWriteU8( address,
896  m_wrBlockMax ,
897  data);
898  data+=sizeof(U8)*m_wrBlockMax;
899  }
900  else {
901  //nWords%m_wrBlockMax
902  unsigned int nwords=nWords-(nXfer-1)*m_wrBlockMax;
903  verbose("Writing last block "+itos(i)+
904  " of size "+itos(nwords),
905  "UsbFTInterface::write");
906  status = usbWriteU8( address,
907  nwords,
908  data);
909  data+=sizeof(U8)*(nwords);
910  }
911  }
912  }
913  break;
914  case (IOdata::Word):
915  status = usbWriteU16(address, nWords, io->dataU16());
916  break;
917  case (IOdata::DWord):
918  status = usbWriteU32(address, nWords, io->dataU32());
919  break;
920  default:
921  error("Wrong word size.","UsbFTInterface::read");
922  status=StatusCode::FAILURE;
923  }
924  return status;
925 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
U32 address()
Definition: IOdata.h:59
unsigned char U8
U32 * dataU32()
Definition: IOdata.h:222
unsigned char U8
Definition: ICECALv3.h:55
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
StatusCode usbWriteU32(unsigned long int, unsigned long int, unsigned long *)
U32 length()
Definition: IOdata.h:175
U16 * dataU16()
Definition: IOdata.h:218
StatusCode usbWriteU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbWriteU8(unsigned long int, unsigned long int, unsigned char *)
U8 * dataU8()
Definition: IOdata.h:214
IOdata::WordSize wordSize()
Definition: IOdata.h:133

◆ write() [2/2]

StatusCode UsbFTInterface::write ( unsigned long int  address,
boost::python::list  obj 
)

Python interpreter wrapping for usb write

Definition at line 196 of file UsbFTInterface.cpp.

References shell::data(), Object::error(), StatusCode::FAILURE, itos(), m_wordSize, usbWriteU16(), usbWriteU32(), usbWriteU8(), Object::verbose(), WS_Byte, WS_DWord, and WS_Word.

198 {
199  unsigned long int nWords = len(obj);
200  StatusCode status;
201  verbose("USB Writing :");
202  switch (m_wordSize)
203  {
204  case WS_Byte:
205  {
206  unsigned char *data=new unsigned char[nWords];
207  for(unsigned int i = 0; i < nWords; i++){
208  data[i]=(boost::python::extract<unsigned char>(obj[i]));
209  verbose("Data format is "+itos(WS_Byte),"UsbFTInterface::write");
210  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::write");
211  };
212  status = usbWriteU8(address, nWords, data);
213  delete data;
214  }
215  break;
216  case WS_Word:
217  {
218  unsigned short *data=new unsigned short[nWords];
219  for(unsigned int i = 0; i < nWords; i++){
220  verbose("Data format is "+itos(WS_Word),"UsbFTInterface::write");
221  data[i]=(boost::python::extract<unsigned short>(obj[i]));
222  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::write");
223  };
224  status = usbWriteU16(address, nWords, data);
225  delete data;
226  }
227  break;
228  case WS_DWord:
229  {
230  unsigned long *data=new unsigned long[nWords];
231  for(unsigned int i = 0; i < nWords; i++){
232  data[i]=(boost::python::extract<unsigned long>(obj[i]));
233  verbose("Data format is "+itos(WS_DWord),"UsbFTInterface::write");
234  verbose("wd "+itos(i)+" "+itos(data[i]),"UsbFTInterface::write");
235  }
236  status = usbWriteU32(address, nWords, data);
237  delete data;
238  }
239  break;
240  default:
241  error("Wrong word size.","read");
242  status=StatusCode::FAILURE;
243  }
244  return status;
245 }
std::string itos(int)
Definition: Tools.cpp:46
void verbose(std::string mymsg)
Definition: Object.h:36
unsigned long m_wordSize
void error(std::string mymsg)
Definition: Object.h:40
def data(object, stream=None)
Definition: shell.py:150
StatusCode usbWriteU32(unsigned long int, unsigned long int, unsigned long *)
StatusCode usbWriteU16(unsigned long int, unsigned long int, unsigned short *)
StatusCode usbWriteU8(unsigned long int, unsigned long int, unsigned char *)
def obj()
Definition: shell.py:26

Member Data Documentation

◆ m_deviceDesc

std::string UsbFTInterface::m_deviceDesc
private

Definition at line 496 of file UsbFTInterface.h.

Referenced by deviceDesc(), init(), and setDeviceDesc().

◆ m_fakeErr

unsigned int UsbFTInterface::m_fakeErr
private

Definition at line 505 of file UsbFTInterface.h.

Referenced by fakeErr(), and setFakeErr().

◆ m_interrupts

bool UsbFTInterface::m_interrupts
private

Definition at line 506 of file UsbFTInterface.h.

Referenced by init(), interrupts(), and setInterrupts().

◆ m_latencyTimer

unsigned char UsbFTInterface::m_latencyTimer
private

Definition at line 497 of file UsbFTInterface.h.

Referenced by init(), latencyTimer(), and setLatencyTimer().

◆ m_nFrames

long int UsbFTInterface::m_nFrames
private

Definition at line 502 of file UsbFTInterface.h.

Referenced by nFrames(), and setNFrames().

◆ m_printout

bool UsbFTInterface::m_printout
private

Definition at line 508 of file UsbFTInterface.h.

Referenced by printout(), and setPrintout().

◆ m_rdBlockMax

int UsbFTInterface::m_rdBlockMax
private

Definition at line 509 of file UsbFTInterface.h.

Referenced by rdBlockMax(), read(), and setRdBlockMax().

◆ m_rxBuffer

int UsbFTInterface::m_rxBuffer
private

Definition at line 501 of file UsbFTInterface.h.

Referenced by init(), rxBuffer(), and setBuffer().

◆ m_rxTimeOut

int UsbFTInterface::m_rxTimeOut
private

Definition at line 499 of file UsbFTInterface.h.

Referenced by init(), rxTimeOut(), and setTimeOut().

◆ m_serialNum

std::string UsbFTInterface::m_serialNum
private

Definition at line 495 of file UsbFTInterface.h.

Referenced by init(), serialNum(), and setSerialNum().

◆ m_showEpromState

bool UsbFTInterface::m_showEpromState
private

Definition at line 507 of file UsbFTInterface.h.

Referenced by setShowEpromState(), and showEpromState().

◆ m_txBuffer

int UsbFTInterface::m_txBuffer
private

Definition at line 500 of file UsbFTInterface.h.

Referenced by init(), setBuffer(), and txBuffer().

◆ m_txTimeOut

int UsbFTInterface::m_txTimeOut
private

Definition at line 498 of file UsbFTInterface.h.

Referenced by init(), setTimeOut(), and txTimeOut().

◆ m_usbId

int UsbFTInterface::m_usbId
private

◆ m_wordCount

unsigned long UsbFTInterface::m_wordCount
private

Definition at line 503 of file UsbFTInterface.h.

Referenced by setWordCount(), and wordCount().

◆ m_wordSize

unsigned long UsbFTInterface::m_wordSize
private

Definition at line 504 of file UsbFTInterface.h.

Referenced by read(), setWordSize(), usbRead(), usbWrite(), wordSize(), and write().

◆ m_wrBlockMax

int UsbFTInterface::m_wrBlockMax
private

Definition at line 510 of file UsbFTInterface.h.

Referenced by setWrBlockMax(), wrBlockMax(), and write().


The documentation for this class was generated from the following files: