Skip to content

Commit

Permalink
[rfxcom] Convert unsigned byte to int properly for message length (#1…
Browse files Browse the repository at this point in the history
…0830)

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>
  • Loading branch information
Jamstah committed Jun 10, 2021
1 parent c49166a commit c12e189
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void run() {
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);
Expand Down

0 comments on commit c12e189

Please sign in to comment.