35 #define FTD2XX_API __declspec(dllexport) 37 #define FTD2XX_API __declspec(dllimport) 46 #define FT_OPEN_BY_SERIAL_NUMBER 1 47 #define FT_OPEN_BY_DESCRIPTION 2 53 #define FT_LIST_NUMBER_ONLY 0x80000000 54 #define FT_LIST_BY_INDEX 0x40000000 55 #define FT_LIST_ALL 0x20000000 57 #define FT_LIST_MASK (FT_LIST_NUMBER_ONLY | FT_LIST_BY_INDEX | FT_LIST_ALL) 63 #define FT_BAUD_300 300 64 #define FT_BAUD_600 600 65 #define FT_BAUD_1200 1200 66 #define FT_BAUD_2400 2400 67 #define FT_BAUD_4800 4800 68 #define FT_BAUD_9600 9600 69 #define FT_BAUD_14400 14400 70 #define FT_BAUD_19200 19200 71 #define FT_BAUD_38400 38400 72 #define FT_BAUD_57600 57600 73 #define FT_BAUD_115200 115200 74 #define FT_BAUD_230400 230400 75 #define FT_BAUD_460800 460800 76 #define FT_BAUD_921600 921600 82 #define FT_BITS_8 (unsigned char)8 83 #define FT_BITS_7 (unsigned char)7 84 #define FT_BITS_6 (unsigned char)6 85 #define FT_BITS_5 (unsigned char)5 91 #define FT_STOP_BITS_1 (unsigned char)0 92 #define FT_STOP_BITS_1_5 (unsigned char)1 93 #define FT_STOP_BITS_2 (unsigned char)2 99 #define FT_PARITY_NONE (unsigned char)0 100 #define FT_PARITY_ODD (unsigned char)1 101 #define FT_PARITY_EVEN (unsigned char)2 102 #define FT_PARITY_MARK (unsigned char)3 103 #define FT_PARITY_SPACE (unsigned char)4 109 #define FT_FLOW_NONE 0x0000 110 #define FT_FLOW_RTS_CTS 0x0100 111 #define FT_FLOW_DTR_DSR 0x0200 112 #define FT_FLOW_XON_XOFF 0x0400 117 #define FT_PURGE_RX 1 118 #define FT_PURGE_TX 2 126 #define FT_EVENT_RXCHAR 1 127 #define FT_EVENT_MODEM_STATUS 2 133 #define FT_DEFAULT_RX_TIMEOUT 300 134 #define FT_DEFAULT_TX_TIMEOUT 300 148 using namespace mrpt;
188 m_hmodule = ::LoadLibraryA(
"Ftd2xx.dll");
204 (HMODULE)
m_hmodule,
"FT_GetQueueStatus");
206 (HMODULE)
m_hmodule,
"FT_SetLatencyTimer");
250 unsigned long nConectedDevices;
256 for (
size_t i = 0; i < nConectedDevices; i++)
262 (
void*)(i), (
void*)str, (
unsigned long)(0x40000000 | 1));
267 (
void*)(i), (
void*)str, (
unsigned long)(0x40000000 | 2));
270 outList.push_back(newEntry);
277 void* pArg1,
void* pArg2,
unsigned long dwFlags)
304 void* lpvBuffer,
unsigned long dwBuffSize,
unsigned long* lpdwBytesRead)
316 const void* lpvBuffer,
unsigned long dwBuffSize,
unsigned long* lpdwBytes)
352 unsigned long dwReadTimeout_ms,
unsigned long dwWriteTimeout_ms)
456 <<
"USB ID (Vendor/Product) : " std::ostream & operator<<(std::ostream &o, const TFTDIDevice &d)
Print out all the information of a FTDI device in textual form.
PtrToResetDevice m_pResetDevice
FT_STATUS(__stdcall * PtrToPurge)(unsigned long, unsigned long)
bool isOpen()
Checks whether the chip has been successfully open.
void ftdi_getQueueStatus(unsigned long *lpdwAmountInRxQueue)
FT_STATUS(__stdcall * PtrToRead)(unsigned long, void *, unsigned long, unsigned long *)
void ftdi_write(const void *lpvBuffer, unsigned long dwBuffSize, unsigned long *lpdwBytes)
FT_STATUS(__stdcall * PtrToOpenEx)(void *, unsigned long, unsigned long *)
#define THROW_EXCEPTION(msg)
PtrToSetLatencyTimer m_pSetLatencyTimer
std::string std::string format(std::string_view fmt, ARGS &&... args)
PtrToListDevices m_pListDevices
std::deque< TFTDIDevice > TFTDIDeviceList
Used in CInterfaceFTDI::ListAllDevices.
FT_STATUS(__stdcall * PtrToClose)(unsigned long)
mrpt::containers::circular_buffer< uint8_t > m_readBuffer
Used in Read.
FT_STATUS(__stdcall * PtrToSetLatencyTimer)(unsigned long, unsigned char)
CInterfaceFTDI()
Constructor, which loads driver interface (the DLL under Windows).
void ftdi_listDevices(void *pArg1, void *pArg2, unsigned long dwFlags)
void ListAllDevices(TFTDIDeviceList &outList)
Generates a list with all FTDI devices connected right now.
#define ASSERT_(f)
Defines an assertion mechanism.
std::string ftdi_description
void ftdi_openEx(void *pArg1, unsigned long dwFlags)
void Close()
Close the USB device.
void SetTimeouts(unsigned long dwReadTimeout_ms, unsigned long dwWriteTimeout_ms)
Change read & write timeouts, in milliseconds.
void(*)(unsigned long, unsigned, long) PFT_EVENT_HANDLER
PtrToSetTimeouts m_pSetTimeouts
FT_STATUS(__stdcall * PtrToSetTimeouts)(unsigned long, unsigned long, unsigned long)
FT_STATUS(__stdcall * PtrToWrite)(unsigned long, const void *, unsigned long, unsigned long *)
void OpenBySerialNumber(const std::string &serialNumber)
Open by device serial number.
void ftdi_open(void *pvDevice)
void ResetDevice()
Reset the USB device.
FT_STATUS(__stdcall * PtrToResetDevice)(unsigned long)
FT_STATUS(__stdcall * PtrToOpen)(void *, unsigned long *)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void ftdi_read(void *lpvBuffer, unsigned long dwBuffSize, unsigned long *lpdwBytesRead)
#define FT_OPEN_BY_SERIAL_NUMBER
FT_STATUS(__stdcall * PtrToListDevices)(void *, void *, unsigned long)
void checkErrorAndRaise(int errorCode)
#define FT_OPEN_BY_DESCRIPTION
Serial and networking devices and utilities.
PtrToGetQueueStatus m_pGetQueueStatus
std::string ftdi_manufacturer
~CInterfaceFTDI() override
Destructor, which closes the connection with the chip and unloads the driver interface.
A list of FTDI devices and their descriptors.
void clear()
Delete all the stored data, if any.
void SetLatencyTimer(unsigned char latency_ms)
Change the latency timer (in milliseconds) implemented on the FTDI chip: for a few ms...
void OpenByDescription(const std::string &description)
Open by device description.
FT_STATUS(__stdcall * PtrToGetQueueStatus)(unsigned long, unsigned long *)
void Purge()
Purge the I/O buffers.