14 std::stringstream msg;
15 msg <<
"FTD2XX error while " << what <<
": ";
18 msg <<
"FT_INVALID_HANDLE";
21 msg <<
"FT_DEVICE_NOT_FOUND";
24 msg <<
"FT_DEVICE_NOT_OPENED";
30 msg <<
"FT_INSUFFICIENT_RESOURCES";
33 msg <<
"FT_INVALID_PARAMETER";
36 msg <<
"FT_INVALID_BAUD_RATE";
39 msg <<
"FT_DEVICE_NOT_OPENED_FOR_ERASE";
42 msg <<
"FT_DEVICE_NOT_OPENED_FOR_WRITE";
45 msg <<
"FT_FAILED_TO_WRITE_DEVICE";
48 msg <<
"FT_EEPROM_READ_FAILED";
51 msg <<
"FT_EEPROM_WRITE_FAILED";
54 msg <<
"FT_EEPROM_ERASE_FAILED";
57 msg <<
"FT_EEPROM_NOT_PRESENT";
60 msg <<
"FT_EEPROM_NOT_PROGRAMMED";
63 msg <<
"FT_INVALID_ARGS";
66 msg <<
"FT_NOT_SUPPORTED";
69 msg <<
"FT_OTHER_ERROR";
72 msg <<
"Unknown FTD2XX Error.";
81 DWORD number_of_devices;
85 DWORD FTDI_VID = 0x403;
86 DWORD SEGWAY_PID = 0xe729;
90 }
catch(std::exception &e) {
93 if (result !=
FT_OK) {
101 }
catch(std::exception &e) {
104 if (result !=
FT_OK) {
110 std::cout <<
"Number of devices is: " << number_of_devices << std::endl;
112 std::vector<FT_DEVICE_LIST_INFO_NODE> devices;
113 if (number_of_devices > 0) {
119 }
catch(std::exception &e) {
122 if (result !=
FT_OK) {
126 for (
int i = 0; i < number_of_devices; i++) {
127 devices.push_back(device_info[i]);
129 printf(
"Dev %d:\n", i);
130 printf(
" Flags=0x%x\n", device_info[i].Flags);
131 printf(
" Type=0x%x\n", device_info[i].Type);
132 printf(
" ID=0x%x\n", device_info[i].ID);
133 printf(
" LocId=0x%x\n", device_info[i].LocId);
134 printf(
" SerialNumber=%s\n", device_info[i].SerialNumber);
135 printf(
" Description=%s\n", device_info[i].Description);
146 : configured(false), config_type(
by_none), baudrate(460800), is_open(false)
161 RMP_THROW_MSG(ConnectionFailedException,
"The usb port must be " 162 "configured before connecting.");
182 RMP_THROW_MSG(ConnectionFailedException,
"The usb port must be " 183 "configured before connecting.");
192 }
catch(std::exception &e) {
195 if (result !=
FT_OK) {
204 }
catch(std::exception &e) {
207 if (result !=
FT_OK) {
215 }
catch(std::exception &e) {
218 if (result !=
FT_OK) {
226 }
catch(std::exception &e) {
229 if (result !=
FT_OK) {
237 }
catch(std::exception &e) {
240 if (result !=
FT_OK) {
263 }
catch(std::exception &e) {
266 if (result !=
FT_OK) {
280 }
catch(std::exception &e) {
283 if (result !=
FT_OK) {
288 return bytes_written;
306 DWORD number_of_devices;
313 }
catch(std::exception &e) {
340 }
catch(std::exception &e) {
343 if (result !=
FT_OK) {
365 }
catch(std::exception &e) {
int read(unsigned char *buffer, int size)
void configureUSBByDescription(std::string description, int baudrate)
#define FT_OPEN_BY_DESCRIPTION
std::vector< FT_DEVICE_LIST_INFO_NODE > enumerateUSBDevices_()
#define FT_OPEN_BY_SERIAL_NUMBER
void connectByDescription()
ConfigurationType config_type
int write(unsigned char *buffer, int size)
FTD2XX_API FT_STATUS WINAPI FT_Open(int deviceNumber, FT_HANDLE *pHandle)
static const bool ftd2xx_devices_debug
FTD2XX_API FT_STATUS FT_SetVIDPID(DWORD dwVID, DWORD dwPID)
FTD2XX_API FT_STATUS WINAPI FT_SetBaudRate(FT_HANDLE ftHandle, ULONG BaudRate)
FTD2XX_API FT_STATUS WINAPI FT_SetTimeouts(FT_HANDLE ftHandle, ULONG ReadTimeout, ULONG WriteTimeout)
FTD2XX_API FT_STATUS WINAPI FT_Purge(FT_HANDLE ftHandle, ULONG Mask)
FTD2XX_API FT_STATUS WINAPI FT_CreateDeviceInfoList(LPDWORD lpdwNumDevs)
FT_HANDLE usb_port_handle
FTD2XX_API FT_STATUS WINAPI FT_Close(FT_HANDLE ftHandle)
FTD2XX_API FT_STATUS WINAPI FT_SetFlowControl(FT_HANDLE ftHandle, USHORT FlowControl, UCHAR XonChar, UCHAR XoffChar)
FTD2XX_API FT_STATUS WINAPI FT_SetLatencyTimer(FT_HANDLE ftHandle, UCHAR ucLatency)
std::string port_serial_number
FTD2XX_API FT_STATUS WINAPI FT_Read(FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToRead, LPDWORD lpBytesReturned)
void configureUSBByIndex(unsigned int device_index, int baudrate)
FTD2XX_API FT_STATUS WINAPI FT_OpenEx(PVOID pArg1, DWORD Flags, FT_HANDLE *pHandle)
std::string getErrorMessageByFT_STATUS(FT_STATUS result, std::string what)
void configureUSBBySerial(std::string serial_number, int baudrate)
std::string port_description
FTD2XX_API FT_STATUS WINAPI FT_Write(FT_HANDLE ftHandle, LPVOID lpBuffer, DWORD dwBytesToWrite, LPDWORD lpBytesWritten)
FTD2XX_API FT_STATUS WINAPI FT_GetDeviceInfoList(FT_DEVICE_LIST_INFO_NODE *pDest, LPDWORD lpdwNumDevs)
#define RMP_THROW_MSG(ExceptionClass, Message)
std::vector< FT_DEVICE_LIST_INFO_NODE > enumerateUSBDevices()