3 Replies Latest reply on Sep 8, 2011 12:49 AM by anand.srinivasan.asokan

    CyUSB DeviceIOControl returns TRUE if device is unexpectedly disconnected

    arturas.isajenko

      Hi,

         
         

      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 3.4.6.0 ). Parts of my code for driver opening & read:

         
         

      //open

         
         

      DeviceHandle = ::CreateFile (functionClassDeviceData->DevicePath,

       
      GENERIC_WRITE | GENERIC_READ,

       
      FILE_SHARE_WRITE | FILE_SHARE_READ,

        NULL,

        OPEN_EXISTING,

        NULL,

        NULL);

         
         

      //...

         
         

      //read

         
         

      unsigned long BytesReturned=0;

      bool result=::DeviceIoControl (DeviceHandle, IOCTL_ADAPT_SEND_NON_EP0_DIRECT,

        &Request, sizeof(Request), buf, buflen,

        &BytesReturned, NULL);

         
         

      Best regards,

         
         

      Arturas