Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

Timeout not right amount of time #362

Closed ZacharyInDallas closed 2 years ago

ZacharyInDallas commented 3 years ago

I'm running under Linux. I set the setComPortTimeouts, but the timeout does not happen in the right amount of time. I am using readLine to do the reads.

Using TIMEOUT_READ_SEMI_BLOCKING, a value of 50000 gives 25 seconds rather than 50 seconds. Using TIMEOUT_READ_SEMI_BLOCKING, a value of 60000 gives 10 seconds rather than 50 seconds. Using TIMEOUT_READ_BLOCKING, a value of 50000 gives 2:28 rather than 50 seconds.

serialPort.setComPortTimeouts (SerialPort.TIMEOUT_READ_SEMI_BLOCKING, 50000, 0); // gives 25 seconds for semi-blocking, 2:28 for full blocking

ZacharyInDallas commented 3 years ago

I also tried using readLine in a SerialPortDataListener. The same timeouts don't work at all there.

hedgecrw commented 3 years ago

You say you are using readLine(), so I assume that means you're wrapping something in a BufferedReader somewhere? If that's the case, please just do a plain read() on the SerialPort object and see if it times out as expected. Wrapping your read calls (and using a newline-delimited read such as readLine()) will definitely affect the timing of the method returns, which has nothing to do with jSerialComm. Please post back if your raw read() calls are not timing out as expected. Thanks!

hedgecrw commented 2 years ago

Closing this issue as "not a bug." Please re-open if you have more information to add. Thanks!