11 #include <mrpt/config.h>
35 #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE)
38 void* usb_device_struct;
122 unsigned long dwReadTimeout_ms,
unsigned long dwWriteTimeout_ms);
131 size_t ReadSync(
void* Buffer,
size_t Count) {
return Read(Buffer, Count); }
137 return Write(Buffer, Count);
155 size_t Read(
void* Buffer,
size_t Count);
164 size_t Write(
const void* Buffer,
size_t Count);
180 void* lpvBuffer,
unsigned long dwBuffSize,
181 unsigned long* lpdwBytesRead);
183 const void* lpvBuffer,
unsigned long dwBuffSize,
184 unsigned long* lpdwBytes);
186 #if defined(MRPT_OS_WINDOWS)
188 void checkErrorAndRaise(
int errorCode);
190 void ftdi_open(
void* pvDevice);
191 void ftdi_openEx(
void* pArg1,
unsigned long dwFlags);
192 void ftdi_listDevices(
void* pArg1,
void* pArg2,
unsigned long dwFlags);
193 void ftdi_getQueueStatus(
unsigned long* lpdwAmountInRxQueue);
196 unsigned long m_ftHandle;
200 enum FT_STATUS{dummy};
202 typedef FT_STATUS(__stdcall* PtrToOpen)(
void*,
unsigned long*);
205 typedef FT_STATUS(__stdcall* PtrToOpenEx)(
206 void*,
unsigned long,
unsigned long*);
207 PtrToOpenEx m_pOpenEx;
209 typedef FT_STATUS(__stdcall* PtrToListDevices)(
void*,
void*,
unsigned long);
210 PtrToListDevices m_pListDevices;
212 typedef FT_STATUS(__stdcall* PtrToClose)(
unsigned long);
215 typedef FT_STATUS(__stdcall* PtrToRead)(
216 unsigned long,
void*,
unsigned long,
unsigned long*);
219 typedef FT_STATUS(__stdcall* PtrToWrite)(
220 unsigned long,
const void*,
unsigned long,
unsigned long*);
223 typedef FT_STATUS(__stdcall* PtrToResetDevice)(
unsigned long);
224 PtrToResetDevice m_pResetDevice;
226 typedef FT_STATUS(__stdcall* PtrToPurge)(
unsigned long,
unsigned long);
229 typedef FT_STATUS(__stdcall* PtrToSetTimeouts)(
230 unsigned long,
unsigned long,
unsigned long);
231 PtrToSetTimeouts m_pSetTimeouts;
233 typedef FT_STATUS(__stdcall* PtrToGetQueueStatus)(
234 unsigned long,
unsigned long*);
235 PtrToGetQueueStatus m_pGetQueueStatus;
237 typedef FT_STATUS(__stdcall* PtrToSetLatencyTimer)(
238 unsigned long,
unsigned char);
239 PtrToSetLatencyTimer m_pSetLatencyTimer;
A definition of a CStream actually representing a USB connection to a FTDI chip.
virtual ~CInterfaceFTDI()
Destructor, which closes the connection with the chip and unloads the driver interface.
uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning)
This virtual method does nothing in this class.
uint64_t getTotalBytesCount()
This virtual method does nothing in this class.
void OpenByDescription(const std::string &description)
Open by device description.
void ResetDevice()
Reset the USB device.
CInterfaceFTDI()
Constructor, which loads driver interface (the DLL under Windows).
void recursive_fill_list_devices(void *usb_device_structure, TFTDIDeviceList &outList)
Process recursively a USB device and its children:
virtual size_t ReadBufferImmediate(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer, and returns the amound of bytes actually read,...
size_t Write(const void *Buffer, size_t Count)
Introduces a pure virtual method responsible for writing to the stream.
bool isOpen()
Checks whether the chip has been successfully open.
void Purge()
Purge the I/O buffers.
void SetTimeouts(unsigned long dwReadTimeout_ms, unsigned long dwWriteTimeout_ms)
Change read & write timeouts, in milliseconds.
void Close()
Close the USB device.
void SetLatencyTimer(unsigned char latency_ms)
Change the latency timer (in milliseconds) implemented on the FTDI chip: for a few ms,...
void ftdi_read(void *lpvBuffer, unsigned long dwBuffSize, unsigned long *lpdwBytesRead)
void ListAllDevices(TFTDIDeviceList &outList)
Generates a list with all FTDI devices connected right now.
CInterfaceFTDI(const CInterfaceFTDI &o)
This object cannot be copied.
size_t ReadSync(void *Buffer, size_t Count)
Tries to read, raising no exception if not all the bytes are available, but raising one if there is s...
mrpt::utils::circular_buffer< uint8_t > m_readBuffer
Used in Read.
void OpenBySerialNumber(const std::string &serialNumber)
Open by device serial number.
size_t WriteSync(const void *Buffer, size_t Count)
Tries to write, raising no exception if not all the bytes are available, but raising one if there is ...
uint64_t getPosition()
This virtual method does nothing in this class.
void ftdi_write(const void *lpvBuffer, unsigned long dwBuffSize, unsigned long *lpdwBytes)
CInterfaceFTDI & operator=(const CInterfaceFTDI &o)
This object cannot be copied.
size_t Read(void *Buffer, size_t Count)
Introduces a pure virtual method responsible for reading from the stream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
GLsizei const GLchar ** string
std::ostream & operator<<(std::ostream &o, const TFTDIDevice &d)
Print out all the information of a FTDI device in textual form.
std::deque< TFTDIDevice > TFTDIDeviceList
Used in CInterfaceFTDI::ListAllDevices.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
unsigned __int16 uint16_t
unsigned __int64 uint64_t
A list of FTDI devices and their descriptors.
std::string ftdi_description
std::string ftdi_manufacturer