Without this, any message over 127 bytes reports a negative length and
fails the message start test, which puts the code out of sync with the
rfxcom leading to lots of errors, and eventually, complete loss of
connection.
Signed-off-by: James Hewitt <james.hewitt@uk.ibm.com>
while (!Thread.interrupted()) {
// First byte tells us how long the packet is
int bytesRead = connector.read(buf, 0, 1);
- int packetLength = buf[0];
+ int packetLength = Byte.toUnsignedInt(buf[0]);
if (bytesRead > 0 && packetLength > 0) {
logger.trace("Message length is {} bytes", packetLength);