[rfxcom] Convert unsigned byte to int properly for message length (#10830)

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>
This commit is contained in:
James Hewitt 2021-06-10 13:30:08 +01:00 committed by GitHub
parent c49166a069
commit c12e189a13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -62,7 +62,7 @@ public class RFXComStreamReader extends Thread {
while (!Thread.interrupted()) { while (!Thread.interrupted()) {
// First byte tells us how long the packet is // First byte tells us how long the packet is
int bytesRead = connector.read(buf, 0, 1); int bytesRead = connector.read(buf, 0, 1);
int packetLength = buf[0]; int packetLength = Byte.toUnsignedInt(buf[0]);
if (bytesRead > 0 && packetLength > 0) { if (bytesRead > 0 && packetLength > 0) {
logger.trace("Message length is {} bytes", packetLength); logger.trace("Message length is {} bytes", packetLength);