Click here to Skip to main content
15,745,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm developing a UWP application that opens a
"SerialDevice" that is a CYPRESS ARM
micrcontroller with "Azure RTOS" and "USBX" library.

The "USBX" library instantiates CDC ACM connection.

The micrcontroller send every second a USB packet with a unknown length from 8 to 512 bytes.

I have to read this packet in my UWP application.

I use this code.

async void my_routine(SerialDevice serialDevice)

  var dataReader = new DataReader(serialDevice.InputStream)
    InputStreamOptions = InputStreamOptions.Partial

     // wait packet
     await dataReader.LoadAsync(512);

     // Read first byte that is an OPERATION_CODE
     var opCode = dataReader.ReadByte();

I don't understand why the code stucks at

await dataReader.LoadAsync(512);

even if I set

InputStreamOptions = InputStreamOptions.Partial

where microsoft ensures

The asynchronous read operation completes when one or more bytes is available.

Can someone help me ?

What I have tried:

I try not to use

await dataReader.LoadAsync(512);

I try to use

await dataReader.LoadAsync(1);

and calculate how many bytes from OPERATION_CODE
Gerry Schmitz 4-Feb-21 10:10am    
Seems there a lot more to the story than what you're showing.
Mauro Fantina 5-Feb-21 2:13am    
What I'm missing ?
Gerry Schmitz 5-Feb-21 6:41am    
You've shown a useless code "fragment" ... we're supposed to "assume" you did the proper setup. Some of us don't (assume).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900