I am observing that InputStreamOptions.Partial isn't really acting partially, but typically requires 50% of the buffer to be full before it returns.
fyi, this is in a loop:
IBuffer blob = await SerialDeviceConnectedToRadioRX.InputStream.ReadAsync(new Windows.Storage.Streams.Buffer(10), 10, InputStreamOptions.Partial);
More precisely, I have a device that I sent commands to and the device responds back. And, for example, when I send it a 7 byte command, I expect it to be sending me a 7 byte block and then another 8 byte block.
What happens is that when I sent the 7 byte block to the device, the above call correctly gets the 1st 7 byte block I am expecting back AND it gets 3 bytes of the 2nd 8 byte block I am expecting - this is all good. As the loops goes to the 2nd iteration of the call, I expect this to happen:
- because .Partial is used, the remaining 5 byte block is returned
- the documentation says:
|
Partial |
1 |
The asynchronous read operation completes when one or more bytes is available. |
|
|
|
|
However, the 5 byte block doesn't get returned until a few more bytes are in the buffer (from another command I send out).
From observation, the trigger is about 50% of the buffer size to equate to "partial".
This seems like a bug to me.
I also tried the .ReadAhead and .None and this didn't help the situation.
Thank you for your advice and time.