I am using FTDI D2XX Programmer's Guide to interact with FTDI serial-to-usb converter. The following code is used to open the USB port.
bool CUsbPort::OpenIOHandle()
{
m_hComm = FT_W32_CreateFile(m_SerialNumberBuf,
GENERIC_READ | GENERIC_WRITE,
0,
0,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED | FT_OPEN_BY_SERIAL_NUMBER,
0);
return m_hComm == INVALID_HANDLE_VALUE ? false : true ;
}
We have a service application to open the port every 5 or 10 minutes to read from and write to our devices. This is a multi-threaded application. I may have more than two devices connected to this application at the same time. When the application runs overnight, I observed there are several cases where FT_W32_CreateFile function failed for all of the threads. Then, they worked again. There may be 2 or 3 times in a overnight run. I want to know what conditions may cause the function failing. Thanks in advance.