From c12e189a133e0aefdc5456a5e807bad39f04e30c Mon Sep 17 00:00:00 2001 From: James Hewitt Date: Thu, 10 Jun 2021 13:30:08 +0100 Subject: [PATCH] [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 --- .../binding/rfxcom/internal/connector/RFXComStreamReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/connector/RFXComStreamReader.java b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/connector/RFXComStreamReader.java index f99866327..33da3b045 100644 --- a/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/connector/RFXComStreamReader.java +++ b/bundles/org.openhab.binding.rfxcom/src/main/java/org/openhab/binding/rfxcom/internal/connector/RFXComStreamReader.java @@ -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);