NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
345 stars 143 forks source link

Available bytes are not readable #74

Closed sitec-mast closed 4 years ago

sitec-mast commented 8 years ago

Hi,

we use nrjavaserial (3.11.0) in our AT command framework jModuleConnect. But now we have an issue with reading in a obscure constellation. After a while of running without problems occurs following issue. The method available() of SerialInputStream delivers 9 or more bytes are available but the following read(byte[], int, int) delivers 0. After that its impossible to remove the bytes from available() neither read(byte[], int, int) or skip(int) will remove the count from available(). And the read delivers only 0 or -1.

We can reproduce the issue easy but at the moment only with a big project application. With a minimal test app was not reproducable at the moment. The only think that was anyway identical, that was the position in buffer at reading (1024 966 58 from nrjavaserial debug). The problem occurs every on this buffer position. The buffer has an size of 1024 and cames from BufferedInputStream.

Here are a part of the log:

    sendEvent return
Entering RXTXPort:SerialOutputStream:write(9) 
Leaving RXTXPort:SerialOutputStream:write(9)
RXTXPort:SerialOutputStream:flush() enter
RXTXPort:SerialOutputStream:flush() leave
RXTXPort:sendEvent(
DATA_AVAILABLE true)
    checking flags 
    getting event
    sending event
2016-03-24 16:06:29:676 DEBUG [Thread-6] d.s.j.CommHandlerImpl SE-EVENT
RXTXPort:available() called
RXTXPort:available() returning 9
2016-03-24 16:06:29:691 DEBUG [Thread-6] d.s.j.CommHandlerImpl Check: AtImpl
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:704 INFO [Thread-6] d.s.j.a.AtImpl Check AT protocol - 0
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:718 DEBUG [Thread-6] d.s.j.DebugInputStream IN: 45 OUT: 45
RXTXPort:SerialInputStream:read(1024 966 58) called
RXTXPort:SerialInputStream:read(1024 966 58) returned 0 bytes
2016-03-24 16:06:29:734 DEBUG [Thread-6] d.s.j.DebugInputStream Read-Meth: 1024-966-58-0
2016-03-24 16:06:29:738 INFO [Thread-6] d.s.j.a.AtImpl Test skip
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
RXTXPort:available() called
RXTXPort:available() returning 45
2016-03-24 16:06:29:759 DEBUG [Thread-6] d.s.j.DebugInputStream IN: 45 OUT: 45
RXTXPort:SerialInputStream:read(1024 966 58) called
RXTXPort:SerialInputStream:read(1024 966 58) returned 0 bytes
2016-03-24 16:06:29:773 DEBUG [Thread-6] d.s.j.DebugInputStream Read-Meth: 1024-966-58-0

I have no idea is an bug in nrjavaserial or and usage mistake of us...

madhephaestus commented 4 years ago

stale closing