]> git.basschouten.com Git - openhab-addons.git/commitdiff
[lcn] add workaround for dynamic text firmware bug (#9232)
authorFabian Wolter <github@fabian-wolter.de>
Sat, 5 Dec 2020 05:22:47 +0000 (06:22 +0100)
committerGitHub <noreply@github.com>
Sat, 5 Dec 2020 05:22:47 +0000 (21:22 -0800)
Some LCN-GTxD don't display the text if it fits exactly in one chunk (12 bytes). Observed with GT10D 8.0.

Closes #9208

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
bundles/org.openhab.binding.lcn/src/main/java/org/openhab/binding/lcn/internal/LcnModuleActions.java
bundles/org.openhab.binding.lcn/src/test/java/org/openhab/binding/lcn/internal/ModuleActionsTest.java

index 9f98e14f1c6fbf352b473228083a09e665e52a66..990eb4eef6103e274089555e2787d111f86a2175 100644 (file)
@@ -125,6 +125,11 @@ public class LcnModuleActions implements ThingActions {
                 text = new String();
             }
 
+            // some LCN-GTxD don't display the text if it fits exactly in one chunk. Observed with GT10D 8.0.
+            if (text.getBytes(LcnDefs.LCN_ENCODING).length % DYN_TEXT_CHUNK_LENGTH == 0) {
+                text += " ";
+            }
+
             // convert String to bytes to split the data every 12 bytes, because a unicode character can take more than
             // one byte
             ByteBuffer bb = ByteBuffer.wrap(text.getBytes(LcnDefs.LCN_ENCODING));
index 57be019be473090b468c7452f63158a07c3f7a03..7f55c73b278ea0da85e1424182577a19e9df7185 100644 (file)
@@ -63,7 +63,10 @@ public class ModuleActionsTest {
     public void testSendDynamicText1ChunkRow1() throws LcnException {
         a.sendDynamicText(1, "abcdfghijklm");
 
-        verify(handler).sendPck(stringToByteBuffer("GTDT11abcdfghijklm"));
+        verify(handler, times(2)).sendPck(byteBufferCaptor.capture());
+
+        assertThat(byteBufferCaptor.getAllValues(), contains(stringToByteBuffer("GTDT11abcdfghijklm"),
+                stringToByteBuffer("GTDT12 \0\0\0\0\0\0\0\0\0\0\0")));
     }
 
     @Test