SerialPort.BaseStream.ReadAsync throws IOException

435 Views Asked by At

When I try to send data to the serial port, it works fine. But when I try to read one byte from the port, reading operation immediately throws IOException (Additional information: Reached the end of the file). I use the following code:

byte[] buff = new byte[1];
await port.BaseStream.ReadAsync(buff, 0, 1); // Exception arises here

I tried to set port.BaseStream.ReadTimeout = 1000 after configuring the port, but I'm still getting the same exception.

Call stack of main thread and another one. Btw, not sure if this is incorrect, but local variables values in non-main thread never appear in the debugging window, neither before exception arises nor after.

0

There are 0 best solutions below