Menu

#21 Bug in libnodave-java which limits readable bytes to just 102

v1.0 (example)
open
None
1
2016-03-18
2016-03-18
Ralf Kern
No

There is a bug in libnodave-java, which only allows to get 102 Bytes per read.
In TCPConnection please change readIsoPacket() to:

    protected int readISOPacket() {
        int res = iface.read(msgIn, 0, 4);
        if (res == 4) {
            //int len = 0x100 * msgIn[2] + msgIn[3]; --> wrong code
            int len = 0x100 *(msgIn[2] & 0xFF) + (msgIn[3] & 0xFF)
            res += iface.read(msgIn, 4, len);
        } else return 0;
        return res;
    }

In Java all Bytes are signed, but you were assuming an unsigned Byte here.
With this error you will only get 127 Bytes at max - minus header of 25 Bytes, you are getting only 102 Bytes at max.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB