CyUSB DeviceIOControl returns TRUE if device is unexpectedly disconnected | Cypress Semiconductor
CyUSB DeviceIOControl returns TRUE if device is unexpectedly disconnected
In my Win32 application I use direct calls to CyUSB driver via DeviceIOControl. The problem is that if I read from pipe (read is blocking, synchronous) and during it device is unexpectedly disconnected, DeviceIOControl returns true. Returning false in such case seems to be more logical I think. Also, when I used older version of FX2 driver EzUSB behaviour in same situation was correct - in case of disconnection DeviceIOControl returned me false.
Is this a bug in driver implementation? If no, please advise how to determine such sudden device disconnections. Thank you.
Technical details: I use Windows 7 32 bit and the latest driver version at the moment ( from
CySuiteUSB_3_4_6_B203.exe , driver version 22.214.171.124 ). Parts of my code for driver opening & read:
DeviceHandle = ::CreateFile (functionClassDeviceData->DevicePath,
GENERIC_WRITE | GENERIC_READ,
FILE_SHARE_WRITE | FILE_SHARE_READ,
unsigned long BytesReturned=0;
bool result=::DeviceIoControl (DeviceHandle, IOCTL_ADAPT_SEND_NON_EP0_DIRECT,
&Request, sizeof(Request), buf, buflen,