You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2022/03/01 17:59:07 UTC

[plc4x] branch develop updated: feat(protocols/c-bus): added StandardFormatStatusReply

This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new ed223d5  feat(protocols/c-bus): added StandardFormatStatusReply
ed223d5 is described below

commit ed223d56f4c3099896e69ebd6db206d67baa72e1
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Tue Mar 1 18:58:20 2022 +0100

    feat(protocols/c-bus): added StandardFormatStatusReply
---
 .../apache/plc4x/java/cbus/RandomPackagesTest.java | 31 ++++++++++++++++++++
 .../src/main/resources/protocols/cbus/c-bus.mspec  | 34 ++++++++++++++++++++++
 2 files changed, 65 insertions(+)

diff --git a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
index d2a2c74..180f490 100644
--- a/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
+++ b/plc4j/drivers/c-bus/src/test/java/org/apache/plc4x/java/cbus/RandomPackagesTest.java
@@ -134,6 +134,37 @@ public class RandomPackagesTest {
                 .isNotNull();
             System.out.println(msg);
         }
+
+        // 7.3
+        @Test
+        void StandardFormatStatusReply1() throws Exception {
+            byte[] bytes = Hex.decodeHex("D8380068AA0140550550001000000014000000000000000000CF" + CR + LF);
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
+            assertThat(msg)
+                .isNotNull();
+            System.out.println(msg);
+        }
+
+        @Test
+        void StandardFormatStatusReply2() throws Exception {
+            byte[] bytes = Hex.decodeHex("D838580000000000000000000000000000000000000000000098" + CR + LF);
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
+            assertThat(msg)
+                .isNotNull();
+            System.out.println(msg);
+        }
+
+        @Test
+        void StandardFormatStatusReply3() throws Exception {
+            byte[] bytes = Hex.decodeHex("D638B000000000FF00000000000000000000000000000043" + CR + LF);
+            ReadBufferByteBased readBufferByteBased = new ReadBufferByteBased(bytes);
+            StandardFormatStatusReply msg = StandardFormatStatusReply.staticParse(readBufferByteBased, false);
+            assertThat(msg)
+                .isNotNull();
+            System.out.println(msg);
+        }
     }
 
 }
diff --git a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
index a09c68f..74dec27 100644
--- a/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
+++ b/protocols/c-bus/src/main/resources/protocols/cbus/c-bus.mspec
@@ -550,4 +550,38 @@
 
 [type Checksum
     [simple byte crc]
+]
+
+[type StandardFormatStatusReply
+    [simple StatusHeader statusHeader]
+    [simple     Application
+                        application                                 ]
+    [simple     uint 8  blockStart                                  ]
+    [array      StatusByte
+                        statusBytes
+                        count
+                        'statusHeader.numberOfCharacterPairs - 2'   ]
+    [simple     Checksum
+                        crc                                         ]
+    [const      byte    cr  0x0D                                    ] // 0xD == "<cr>"
+    [const      byte    lf  0x0A                                    ] // 0xA == "<lf>"
+]
+
+[type StatusHeader
+    [reserved   uint 2                 '1'                          ]
+    [simple     uint 6  numberOfCharacterPairs                      ]
+]
+
+[type StatusByte
+    [simple GAVState    gav3                                        ]
+    [simple GAVState    gav2                                        ]
+    [simple GAVState    gav1                                        ]
+    [simple GAVState    gav0                                        ]
+]
+
+[enum uint 2 GAVState
+    ['0' DOES_NOT_EXIST                                             ]
+    ['1' ON                                                         ]
+    ['2' OFF                                                        ]
+    ['3' ERRO                                                       ]
 ]
\ No newline at end of file