33 #define FTD2XX_API __declspec(dllexport) 35 #define FTD2XX_API __declspec(dllimport) 44 #define FT_OPEN_BY_SERIAL_NUMBER 1 45 #define FT_OPEN_BY_DESCRIPTION 2 51 #define FT_LIST_NUMBER_ONLY 0x80000000 52 #define FT_LIST_BY_INDEX 0x40000000 53 #define FT_LIST_ALL 0x20000000 55 #define FT_LIST_MASK (FT_LIST_NUMBER_ONLY | FT_LIST_BY_INDEX | FT_LIST_ALL) 61 #define FT_BAUD_300 300 62 #define FT_BAUD_600 600 63 #define FT_BAUD_1200 1200 64 #define FT_BAUD_2400 2400 65 #define FT_BAUD_4800 4800 66 #define FT_BAUD_9600 9600 67 #define FT_BAUD_14400 14400 68 #define FT_BAUD_19200 19200 69 #define FT_BAUD_38400 38400 70 #define FT_BAUD_57600 57600 71 #define FT_BAUD_115200 115200 72 #define FT_BAUD_230400 230400 73 #define FT_BAUD_460800 460800 74 #define FT_BAUD_921600 921600 80 #define FT_BITS_8 (unsigned char)8 81 #define FT_BITS_7 (unsigned char)7 82 #define FT_BITS_6 (unsigned char)6 83 #define FT_BITS_5 (unsigned char)5 89 #define FT_STOP_BITS_1 (unsigned char)0 90 #define FT_STOP_BITS_1_5 (unsigned char)1 91 #define FT_STOP_BITS_2 (unsigned char)2 97 #define FT_PARITY_NONE (unsigned char)0 98 #define FT_PARITY_ODD (unsigned char)1 99 #define FT_PARITY_EVEN (unsigned char)2 100 #define FT_PARITY_MARK (unsigned char)3 101 #define FT_PARITY_SPACE (unsigned char)4 107 #define FT_FLOW_NONE 0x0000 108 #define FT_FLOW_RTS_CTS 0x0100 109 #define FT_FLOW_DTR_DSR 0x0200 110 #define FT_FLOW_XON_XOFF 0x0400 115 #define FT_PURGE_RX 1 116 #define FT_PURGE_TX 2 124 #define FT_EVENT_RXCHAR 1 125 #define FT_EVENT_MODEM_STATUS 2 131 #define FT_DEFAULT_RX_TIMEOUT 300 132 #define FT_DEFAULT_TX_TIMEOUT 300 146 using namespace mrpt;
186 m_hmodule = ::LoadLibraryA(
"Ftd2xx.dll");
202 (HMODULE)
m_hmodule,
"FT_GetQueueStatus");
204 (HMODULE)
m_hmodule,
"FT_SetLatencyTimer");
248 unsigned long nConectedDevices;
254 for (
size_t i = 0; i < nConectedDevices; i++)
260 (
void*)(i), (
void*)str, (
unsigned long)(0x40000000 | 1));
265 (
void*)(i), (
void*)str, (
unsigned long)(0x40000000 | 2));
268 outList.push_back(newEntry);
275 void* pArg1,
void* pArg2,
unsigned long dwFlags)
302 void* lpvBuffer,
unsigned long dwBuffSize,
unsigned long* lpdwBytesRead)
314 const void* lpvBuffer,
unsigned long dwBuffSize,
unsigned long* lpdwBytes)
350 unsigned long dwReadTimeout_ms,
unsigned long dwWriteTimeout_ms)
454 <<
"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
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.
virtual ~CInterfaceFTDI()
Destructor, which closes the connection with the chip and unloads the driver interface.
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.
GLsizei const GLchar ** string
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)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
void checkErrorAndRaise(int errorCode)
#define FT_OPEN_BY_DESCRIPTION
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
Serial and networking devices and utilities.
PtrToGetQueueStatus m_pGetQueueStatus
std::string ftdi_manufacturer
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.