3 Replies Latest reply on Apr 1, 2020 9:46 PM by YatheeshK_36

    How to receive the whole bytes in c#

    YuWa_4674726

      Hi,

      I could send/read the data with C# (cyusb.dll) and every time I read 512 bytes.

      But my full data's size is not a multiple of 512.

      The function WaitForXfer() always returns false if the remaining data's size does not reach 512. These remaining data would interfere with the byte content next time.

      So my question is how to receive these remaining data(less than 512).

       

      Thank you !

       

       

        • 1. Re: How to receive the whole bytes in c#
          YatheeshK_36

          Hello,

           

          For the application to read the data, the data should be committed to the endpoint buffer by the firmware. Please confirm the same.

          You can use the synchronous Xferdata call, where you can specify the length of data that is to be read from the corresponding endpoint.

          Refer to section "4.14.7 XferData( )" from the CyUSB.NET.pdf available in the FX3 SDK.

           

          Thanks,

          Yatheesh

          • 2. Re: How to receive the whole bytes in c#
            YuWa_4674726

            Hello,

            Thank you for reply.

             

            "XferData( )" is a wonderful way.But I hope to receive data continuously by the asynchronous approach.

            So is it possible to read dynamic length data with the dll ?

             

            Thank you!

            • 3. Re: How to receive the whole bytes in c#
              YatheeshK_36

              Hello,

               

              Please check the value in the len field of the FinishDataXfer after it is called. It is supposed to hold the length of the data actually transferred.

              If the endpoint has data, then len field will be non zero. If it is zero, then please check the firmware if the data is actually committed to the endpoint.

              Also, you can use the  UsbdStatus and UsbdStatusString function to get the error from the last Xfer call by passing the return status.

               

              Thanks,

              Yatheesh