How to receive the whole bytes in c#

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
YuWa_4674726
Level 1
Level 1

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 !

0 Likes
1 Solution
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

View solution in original post

0 Likes
3 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

0 Likes

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!

0 Likes

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

0 Likes