Fazecast / jSerialComm

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

May have found a copy/paste bug #504

Closed Jnesselr closed 1 year ago

Jnesselr commented 1 year ago

I'm not 100% sure of the effects of this bug, but I was looking for a bug around the timeout code and noticed in a diff included in the 2.10.0 release what appears to be a copy/paste bug: https://github.com/Fazecast/jSerialComm/commit/68f188b5a4dc3ccf7cfaefedec166e4f454bc575#diff-9541087feadc5da081d98f5090519e547927405e7b1c62938cf69b8ec54c0f7aR974

I think this should say read(port->handle, readBuffer, bytesToRead) but to be clear I have not at all tested that.

hedgecrw commented 1 year ago

This was an intentional change (and I don't think it's a bug). In this particular instance, numBytesReadTotal will have a value equal to the passed in offset, and bytesRemaining will have a value equal to the smaller of bytesToRead or however much space is remaining in the read buffer after the offset. So this all looks correct to me.