-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
I'm getting the following error when trying to asynchronously read a line after writing a command:
System.ArgumentOutOfRangeException: 'Length cannot be less than zero. (Parameter 'length')'
This is the code that triggers the error:
serialPort = new SerialPort(portName: port, baudRate: 9600, parity: Parity.Even, dataBits: 7, stopBits: StopBits.One);
serialPort.NewLine = "\r";
serialPort.ReadTimeout = 1000;
serialPort.WriteTimeout = 1000;
serialPort.Open();
await serialPort.WriteLineAsync("R0");
var result = await serialPort.ReadLineAsync();
If I change the last line to a synchronous ReadLine call it works fine.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels