Hello.
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
};
while(true)
{
await dataReader.LoadAsync(512);
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
Quote:
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