]> git.basschouten.com Git - openhab-addons.git/commitdiff
[rfxcom] Convert unsigned byte to int properly for message length (#10830)
authorJames Hewitt <james.hewitt@gmail.com>
Thu, 10 Jun 2021 12:30:08 +0000 (13:30 +0100)
committerGitHub <noreply@github.com>
Thu, 10 Jun 2021 12:30:08 +0000 (14:30 +0200)
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>
bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/connector/RFXComStreamReader.java

index f9986632775d0b9db7f8a433a3506110480cfbad..33da3b0451edfc887a266978185df97cab989278 100644 (file)
@@ -62,7 +62,7 @@ public class RFXComStreamReader extends Thread {
             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);