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

[plc4x] 02/03: - Continued working on the s7 mspec, especially regarding SZL sublists - Introduced enum types

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

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

commit 9caeb4e582d4ec6f8e0a7ae39ef8d362266e2144
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Oct 10 11:21:26 2019 +0200

    - Continued working on the s7 mspec, especially regarding SZL sublists
    - Introduced enum types
---
 .../s7/src/main/resources/protocols/s7/s7.mspec    | 140 +++++++++++++++++----
 1 file changed, 113 insertions(+), 27 deletions(-)

diff --git a/protocols/s7/src/main/resources/protocols/s7/s7.mspec b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
index c87b93f..af14ad2 100644
--- a/protocols/s7/src/main/resources/protocols/s7/s7.mspec
+++ b/protocols/s7/src/main/resources/protocols/s7/s7.mspec
@@ -33,7 +33,7 @@
 ////////////////////////////////////////////////////////////////
 
 [discriminatedType 'COTPPacket' [uint 16 'cotpLen']
-    [implicit      uint 8 'headerLength' 'lengthInBytes - (payload.lengthInBytes + 1)']
+    [implicit      uint 8 'headerLength' 'lengthInBytes - (((payload != null) ? payload.lengthInBytes : 0) + 1)']
     [discriminator uint 8 'tpduCode']
     [typeSwitch 'tpduCode'
         ['0xF0' COTPPacketData
@@ -41,19 +41,19 @@
             [simple uint 7 'tpduRef']
         ]
         ['0xE0' COTPPacketConnectionRequest
-            [simple uint 16 'destinationReference']
-            [simple uint 16 'sourceReference']
-            [simple uint 8  'protocolClass']
+            [simple uint 16           'destinationReference']
+            [simple uint 16           'sourceReference']
+            [enum   COTPProtocolClass 'protocolClass']
         ]
         ['0xD0' COTPPacketConnectionResponse
-            [simple uint 16 'destinationReference']
-            [simple uint 16 'sourceReference']
-            [simple uint 8  'protocolClass']
+            [simple uint 16           'destinationReference']
+            [simple uint 16           'sourceReference']
+            [enum   COTPProtocolClass 'protocolClass']
         ]
         ['0x80' COTPPacketDisconnectRequest
-            [simple uint 16 'destinationReference']
-            [simple uint 16 'sourceReference']
-            [simple uint 8  'protocolClass']
+            [simple uint 16           'destinationReference']
+            [simple uint 16           'sourceReference']
+            [enum   COTPProtocolClass 'protocolClass']
         ]
         ['0xC0' COTPPacketDisconnectResponse
             [simple uint 16 'destinationReference']
@@ -73,7 +73,7 @@
     [implicit      uint 8 'parameterLength' 'lengthInBytes - 2']
     [typeSwitch 'parameterType'
         ['0xC0' COTPParameterTpduSize
-            [simple uint 8 'tpduSize']
+            [enum COTPTpduSize 'tpduSize']
         ]
         ['0xC1' COTPParameterCallingTsap
             [simple uint 16 'tsapId']
@@ -142,17 +142,17 @@
             [simple uint 8 'numItems']
         ]
         ['0x00','0x07' S7ParameterUserData
-            [implicit uint 8       'numItems' 'COUNT(items)']
-            [array    UserDataItem 'items' count 'numItems']
+            [implicit uint 8                  'numItems' 'COUNT(items)']
+            [array    S7ParameterUserDataItem 'items' count 'numItems']
         ]
     ]
 ]
 
 [discriminatedType 'S7VarRequestParameterItem'
-    [discriminator uint 8 'parameterItemType']
-    [typeSwitch 'parameterItemType'
+    [discriminator uint 8 'itemType']
+    [typeSwitch 'itemType'
         ['0x12' S7VarRequestParameterItemAddress
-            [implicit uint 8    'addressLength' 'address.lengthInBytes']
+            [implicit uint 8    'itemLength' 'address.lengthInBytes']
             [simple   S7Address 'address']
         ]
     ]
@@ -173,22 +173,40 @@
     ]
 ]
 
-// TODO: CPUFunctions still need some love ...
-[discriminatedType 'UserDataItem'
+[discriminatedType 'S7ParameterUserDataItem'
     [discriminator uint 8 'itemType']
     [typeSwitch 'itemType'
-        ['0x12' UserDataItemCPUFunctions
-            [implicit uint 8  'parameterLength' 'lengthInBytes']
-            [simple   uint 16 'cpuFunctionType']
-            [simple   uint 8  'subFunctionGroup']
-            [simple   uint 8  'sequenceNumber']
-            [optional uint 8  'dataUnitReferenceNumber' 'parameterLength == 8']
-            [optional uint 8  'lastDataUnit' 'parameterLength == 8']
-            [optional uint 8  'errorCode' 'parameterLength == 8']
+        ['0x12' S7ParameterUserDataItemCPUFunctions
+            [implicit uint 8 'itemLength' 'lengthInBytes']
+            [simple   uint 8 'method']
+            [simple   uint 4 'cpuFunctionType']
+            [simple   uint 4 'cpuFunctionGroup']
+            [simple   uint 8 'cpuSubfunction']
+            [simple   uint 8 'sequenceNumber']
+            [optional uint 8 'dataUnitReferenceNumber' 'cpuFunctionType == 8']
+            [optional uint 8 'lastDataUnit' 'cpuFunctionType == 8']
+            [optional uint 8 'errorCode' 'cpuFunctionType == 8']
         ]
     ]
 ]
 
+// This part is actually specified: http://www.kleissler-online.de/Siemens/SFCs.pdf
+// http://www.efesotomasyon.com/html/siemens/OP-Liste_en.pdf
+// https://cache.industry.siemens.com/dl/files/697/101906697/att_118286/v1/net_s7-300_s7-400_di_do_drahtbruch_en.pdf
+[type 'SzlId'
+    [enum SzlModuleTypeClass 'typeClass']
+    [simple uint 4           'sublistExtract']
+    [enum SzlSublist         'sublistList']
+]
+
+[type 'SzlDataTreeItem'
+    [simple uint 16 'itemIndex']
+    [array  int 8 'mlfb' count '20']
+    [simple uint 16 'moduleTypeId']
+    [simple uint 16 'ausbg']
+    [simple uint 16 'ausbe']
+]
+
 ////////////////////////////////////////////////////////////////
 // Payloads
 
@@ -206,6 +224,7 @@
             [array S7VarPayloadStatusItem 'items' count 'CAST(parameter, S7ParameterWriteVarResponse).numItems']
         ]
         ['0x00','0x07' S7PayloadUserData
+            [array S7PayloadUserDataItem 'items' count 'COUNT(CAST(parameter, S7ParameterUserData).items)']
         ]
     ]
 ]
@@ -223,6 +242,42 @@
     [simple uint 8 'returnCode']
 ]
 
+[discriminatedType 'S7PayloadUserDataItem'
+    [simple   uint 8 'returnCode']
+    [simple   uint 8 'transportSize']
+    [implicit uint 16 'dataLength' 'lengthInBytes - 4']
+    [simple   SzlId   'szlId']
+    [simple   uint 16 'szlIndex']
+    [typeSwitch ''
+        ['' S7PayloadUserDataItemCpuFunctionReadSzlRequest
+        ]
+        ['' S7PayloadUserDataItemCpuFunctionReadSzlResponse
+            [const    uint 16 'szlItemLength' '28']
+            [implicit uint 16 'szlItemCount'  'COUNT(items)']
+            [array SzlDataTreeItem 'items' count 'szlItemCount']
+        ]
+    ]
+]
+
+
+[enum uint 8 'COTPTpduSize' [uint 8 'sizeInBytes']
+    ['0x07' SIZE_128 ['128']]
+    ['0x08' SIZE_256 ['256']]
+    ['0x09' SIZE_512 ['512']]
+    ['0x0a' SIZE_1024 ['1024']]
+    ['0x0b' SIZE_2048 ['2048']]
+    ['0x0c' SIZE_4096 ['4096']]
+    ['0x0d' SIZE_8192 ['8192']]
+]
+
+[enum uint 8 'COTPProtocolClass'
+    ['0x00' CLASS_0]
+    ['0x10' CLASS_1]
+    ['0x20' CLASS_2]
+    ['0x30' CLASS_3]
+    ['0x40' CLASS_4]
+]
+
 [enum uint 8 'DataTransportSize' [bit 'sizeInBits']
     ['0x00' NULL            ['false']]
     ['0x03' BIT             ['true']]
@@ -249,7 +304,7 @@
     ['0x00' ULINT            ['X'              , '16'                , 'INT'                   , 'null']]
     ['0x08' REAL             ['D'              , '4'                 , 'null'                  , 'DataTransportSize.BYTE_WORD_DWORD']]
     ['0x00' LREAL            ['X'              , '8'                 , 'REAL'                  , 'null']]
-    ['0x0B' TIME             ['X'              , '4'                 , 'null'                  , 'null']
+    ['0x0B' TIME             ['X'              , '4'                 , 'null'                  , 'null']]
     ['0x00' LTIME            ['X'              , '8'                 , 'TIME'                  , 'null']]
     ['0x02' DATE             ['X'              , '2'                 , 'null'                  , 'DataTransportSize.BYTE_WORD_DWORD']]
     ['0x02' TIME_OF_DAY      ['X'              , '4'                 , 'null'                  , 'DataTransportSize.BYTE_WORD_DWORD']]
@@ -260,3 +315,34 @@
     ['0x00' WSTRING          ['X'              , '1'                 , 'null'                  , 'null']]
 ]
 
+[enum uint 4 'SzlModuleTypeClass'
+    ['0x0' CPU]
+    ['0x4' IM]
+    ['0x8' FM]
+    ['0xC' CP]
+]
+
+[enum uint 8 'SzlSublist'
+    ['0x11' MODULE_IDENTIFICATION]
+    ['0x12' CPU_FEATURES]
+    ['0x13' USER_MEMORY_AREA]
+    ['0x14' SYSTEM_AREAS]
+    ['0x15' BLOCK_TYPES]
+    ['0x19' STATUS_MODULE_LEDS]
+    ['0x1C' COMPONENT_IDENTIFICATION]
+    ['0x22' INTERRUPT_STATUS]
+    ['0x25' ASSIGNMENT_BETWEEN_PROCESS_IMAGE_PARTITIONS_AND_OBS]
+    ['0x32' COMMUNICATION_STATUS_DATA]
+    ['0x74' STATUS_SINGLE_MODULE_LED]
+    ['0x90' DP_MASTER_SYSTEM_INFORMATION]
+    ['0x91' MODULE_STATUS_INFORMATION]
+    ['0x92' RACK_OR_STATION_STATUS_INFORMATION]
+    ['0x94' RACK_OR_STATION_STATUS_INFORMATION_2]
+    ['0x95' ADDITIONAL_DP_MASTER_SYSTEM_OR_PROFINET_IO_SYSTEM_INFORMATION]
+    ['0x96' MODULE_STATUS_INFORMATION_PROFINET_IO_AND_PROFIBUS_DP]
+    ['0xA0' DIAGNOSTIC_BUFFER]
+    ['0xB1' MODULE_DIAGNOSTIC_DATA]
+]
+
+
+