I'm trying to implement a ModBus master on Windows 10 IoT on a Raspberry Pi 2. I'm using an external USB to RS-232 adapter since the internal serial port is reserved for Kernel Debugging.
Serial port is working. My question is mainly about timeout when reading.
Here is my code:
// Initialization
serialDevice.ReadTimeout = new TimeSpan(0, 0, 0, allowedTimeBetweenBytes);
serialDataReader.InputStreamOptions = InputStreamOptions.Partial;
// Reading
uint bytesRead = await serialDataReader.LoadAsync(MaxBufferSize); // 256
// Now use ReadBytes to get actual bytes
With no bytes awailable at the serial port RX input, I'm expecting the LoadAsync method to return 0 after wait. Unfortunately, it never returns. (Ok, it DOES return after 256 bytes are received, but that is not what I want)
Since ModBus intensively uses timeouts, I am not sure how to implement it. I am not even sure I could do it...
Does anyone already used timeouts on Windows 10 IoT serial ports?