You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by ld...@apache.org on 2020/10/07 10:02:09 UTC

[plc4x] 14/19: More tests of canopen payload.

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

ldywicki pushed a commit to branch feature/socketcan
in repository https://gitbox.apache.org/repos/asf/plc4x.git

commit 71301c964cba10d3395a6a88e290612d0022baf0
Author: Ɓukasz Dywicki <lu...@code-house.org>
AuthorDate: Tue Sep 1 18:13:32 2020 +0200

    More tests of canopen payload.
---
 .../src/main/resources/protocols/can/canopen.mspec | 67 +++++++++++++++++-----
 .../testsuite/CANOpenPayloadTestSuite.xml          | 41 +++++++++++++
 2 files changed, 94 insertions(+), 14 deletions(-)

diff --git a/protocols/can/src/main/resources/protocols/can/canopen.mspec b/protocols/can/src/main/resources/protocols/can/canopen.mspec
index 0c4f175..c929ae4 100644
--- a/protocols/can/src/main/resources/protocols/can/canopen.mspec
+++ b/protocols/can/src/main/resources/protocols/can/canopen.mspec
@@ -17,20 +17,21 @@
  * under the License.
  */
 
-[enum uint 4 'CANOpenService'
-    ['0b0000' BROADCAST   ]
-    ['0b0001' SYNC        ]
-    ['0b1110' NMT         ]
-    ['0b1100' SDO_REQUEST ]
-    ['0b1011' SDO_RESPONSE]
-    ['0b0011' TPDO_1]
-    ['0b0100' RPDO_1]
-    ['0b0101' TPDO_2]
-    ['0b0110' RPDO_2]
-    ['0b0111' TPDO_3]
-    ['0b1000' RPDO_3]
-    ['0b1001' TPDO_4]
-    ['0b1010' RPDO_4]
+[enum uint 4 'CANOpenService' [bit 'sdo', bit 'pdo', bit 'transmit', bit 'receive']
+    ['0b0000' BROADCAST    ['false', 'false', 'false', 'false'] ]
+    ['0b0001' SYNC         ['false', 'false', 'false', 'false'] ]
+    ['0b0010' TIME         ['false', 'false', 'false', 'false'] ]
+    ['0b1110' NMT          ['false', 'false', 'false', 'false'] ]
+    ['0b1100' SDO_REQUEST  ['true',  'false', 'false', 'true' ] ]
+    ['0b1011' SDO_RESPONSE ['true',  'false', 'true',  'false'] ]
+    ['0b0011' TPDO_1       ['false', 'true',  'true',  'false'] ]
+    ['0b0100' RPDO_1       ['false', 'true',  'false', 'true' ] ]
+    ['0b0101' TPDO_2       ['false', 'true',  'true',  'false'] ]
+    ['0b0110' RPDO_2       ['false', 'true',  'false', 'true' ] ]
+    ['0b0111' TPDO_3       ['false', 'true',  'true',  'false'] ]
+    ['0b1000' RPDO_3       ['false', 'true',  'false', 'true' ] ]
+    ['0b1001' TPDO_4       ['false', 'true',  'true',  'false'] ]
+    ['0b1010' RPDO_4       ['false', 'true',  'false', 'true' ] ]
 ]
 
 [enum uint 8 'NMTStateRequest'
@@ -55,6 +56,9 @@
             [reserved uint 1 '0x00']
             [simple uint 7 'node']
         ]
+        ['CANOpenService.TIME' CANOpenTimeSynchronization
+            [simple TimeOfDay 'timeOfDay']
+        ]
         ['CANOpenService.NMT' CANOpenNetworkPayload
             [enum NMTState 'state']
         ]
@@ -78,6 +82,30 @@
             [simple uint 8 'subindex']
             [array uint 8 'data' COUNT 'size']
         ]
+        ['CANOpenService.RPDO_1' CANOpenRPDO
+            [simple CANOpenPDO 'pdo' ['1', 'true']]
+        ]
+        ['CANOpenService.TPDO_1' CANOpenTPDO
+            [simple CANOpenPDO 'pdo' ['1', 'false']]
+        ]
+        ['CANOpenService.RPDO_2' CANOpenRPDO
+            [simple CANOpenPDO 'pdo' ['2', 'true']]
+        ]
+        ['CANOpenService.TPDO_2' CANOpenTPDO
+            [simple CANOpenPDO 'pdo' ['1', 'false']]
+        ]
+        ['CANOpenService.RPDO_3' CANOpenRPDO
+            [simple CANOpenPDO 'pdo' ['3', 'true']]
+        ]
+        ['CANOpenService.TPDO_3' CANOpenTPDO
+            [simple CANOpenPDO 'pdo' ['1', 'false']]
+        ]
+        ['CANOpenService.RPDO_4' CANOpenRPDO
+            [simple CANOpenPDO 'pdo' ['4', 'true']]
+        ]
+        ['CANOpenService.TPDO_4' CANOpenTPDO
+            [simple CANOpenPDO 'pdo' ['1', 'false']]
+        ]
     ]
 ]
 
@@ -90,3 +118,14 @@
     ['0x05' BLOCK_UPLOAD]
     ['0x06' BLOCK_DOWNLOAD]
 ]
+
+[type 'CANOpenPDO' [uint 2 'index', bit 'receive']
+
+]
+
+[type 'TimeOfDay'
+    // CiA 301 - section 7.1.6.5
+    [simple uint 28 'millis']
+    [reserved int 4 '0x00']
+    [simple uint 16 'days']
+]
\ No newline at end of file
diff --git a/sandbox/test-java-can-driver/src/test/resources/testsuite/CANOpenPayloadTestSuite.xml b/sandbox/test-java-can-driver/src/test/resources/testsuite/CANOpenPayloadTestSuite.xml
index ecf224b..3188005 100644
--- a/sandbox/test-java-can-driver/src/test/resources/testsuite/CANOpenPayloadTestSuite.xml
+++ b/sandbox/test-java-can-driver/src/test/resources/testsuite/CANOpenPayloadTestSuite.xml
@@ -21,6 +21,47 @@
 
   <name>Tests of CANopen frames payload.</name>
 
+
+  <testcase>
+    <name>Time synchronization, payload: A017BD805034</name>
+    <!--
+    Initial test payload was A017BD835034, however it does not align with CANOpen spec or mapping on our side is wrong
+    -->
+    <raw>A017BD805034</raw>
+    <root-type>CANOpenPayload</root-type>
+    <parser-arguments>
+      <arg1>TIME</arg1>
+    </parser-arguments>
+    <xml>
+      <CANOpenTimeSynchronization className="org.apache.plc4x.java.canopen.readwrite.CANOpenTimeSynchronization">
+        <timeOfDay className="org.apache.plc4x.java.canopen.readwrite.TimeOfDay">
+          <millis>-663027446</millis>
+          <days>13392</days>
+        </timeOfDay>
+      </CANOpenTimeSynchronization>
+    </xml>
+  </testcase>
+
+  <testcase>
+    <name>Time synchronization, payload: 7019BE805034</name>
+    <!--
+    Initial test payload was 7019BE835034, however it does not align with CANOpen spec or mapping on our side is wrong
+    -->
+    <raw>7019BE805034</raw>
+    <root-type>CANOpenPayload</root-type>
+    <parser-arguments>
+      <arg1>TIME</arg1>
+    </parser-arguments>
+    <xml>
+      <CANOpenTimeSynchronization className="org.apache.plc4x.java.canopen.readwrite.CANOpenTimeSynchronization">
+        <timeOfDay className="org.apache.plc4x.java.canopen.readwrite.TimeOfDay">
+          <millis>-392494841</millis>
+          <days>13392</days>
+        </timeOfDay>
+      </CANOpenTimeSynchronization>
+    </xml>
+  </testcase>
+
   <testcase>
     <name>Network heartbeat, payload: 00</name>
     <raw>00</raw>