3 Replies Latest reply on Aug 9, 2020 11:29 PM by RashiV_61

    Send USB control command in Linux




      I'm using the FX3 library in windows and linux system.


      At Windows enviroment, i send a command to FX3 Fw using "CCyControlEndPoint->XferData" function. (refer below code)


      CCyControlEndPoint* ept = USBDevices.ControlEndPt;

      ept->Target = TGT_DEVICE; //(0x00)

      ept->ReqCode = 0xBC; // pre-defined in FX3 firmware.

      ept->ReqType = REQ_VENDOR; //(0x40)

      ept->Direction = DIR_TO_DEVICE; //(0x00)

      ept->Value = 0x00;

      ept->Index = 0x00;

      unsigned char  buf[1] = { 0x00};


      bool bXferCompleted = ept->XferData(buf, length);


      At Linux environment, i send a same command using "cyusb_control_transfer" function.


      mHandle = cyusb_gethandle(mDeviceDB->cyDevId);

      unsigned char  buf[1] = { 0x00 };

      cyusb_control_transfer(mHandle, 0x40, 0xBC, 0x00, 0x00, buf, 1, 1000);



      However, It works only Windows environment. Even with the USB monitoring tool, the command seems to be sent well.


      Am I using the function incorrectly in the Linux environment?

      How do I implement it in Linux to send commands the same as in Windows?

        • 1. Re: Send USB control command in Linux



          - Please check if the return value of cyusb_gethandle is non zero or not

          For example:

          mHandle = cyusb_gethandle(mDeviceDB->cyDevId);

          if (!mHandle)


          printf("Error in getting a handle. curent_device_index = %d\n", current_device_index);



          - If the return value of cyusb_gethandle is non zero please check the return value of cyusb_control_transfer

          cyusb_control_transfer returns the actual number of bytes transferred on success, in the range from and including zero up to and including wLength. On error a LIBUSB_ERROR code is returned, for example, LIBUSB_ERROR_TIMEOUT if the transfer timed out, LIBUSB_ERROR_PIPE if the control request was not supported, LIBUSB_ERROR_NO_DEVICE if the device has been disconnected and another LIBUSB_ERROR code on other failures. The LIBUSB_ERROR codes are all negative.




          • 2. Re: Send USB control command in Linux

            I already checked the return values. It seems OK.

            And when i checked using USB monitoring tool (wireshark), the transmitted data looks OK.


            So I was wondering if there is any other way to transfer with the same settings as the function I used in Windows.

            • 3. Re: Send USB control command in Linux



              The CyUSB Suite for Linux is a wrapper around an existing Open Source user-space USB Library called libusb.

              Whereas the  CyAPI.lib provides a simple, powerful C++ programming interface to USB devices. It is a C++ class library that provides a high-level programming interface to the CyUsb3.sys device driver via Windows API.

              CyAPI.lib is not available for Linux so XferData cannot be used in CyUSB Suite for Linux


              Please let me know if any query on this