Skip to content

Commit

Permalink
fix(plc4j/codgen): migrate the protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Oct 22, 2021
1 parent ca05161 commit a17dda1
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
]
['0x03' BVLCReadBroadcastDistributionTableAck
]
['0x04' BVLCForwardedNPDU [uint 16 'bvlcLength']
['0x04' BVLCForwardedNPDU(uint 16 'bvlcLength')
[array uint 8 'ip' count '4' ]
[simple uint 16 'port' ]
[simple NPDU 'npdu' ['bvlcLength - 10']]
[simple NPDU('bvlcLength - 10') 'npdu' ]
]
['0x05' BVLCRegisterForeignDevice
]
Expand All @@ -45,18 +45,18 @@
]
['0x09' BVLCDistributeBroadcastToNetwork
]
['0x0A' BVLCOriginalUnicastNPDU [uint 16 'bvlcLength']
[simple NPDU 'npdu' ['bvlcLength - 4']]
['0x0A' BVLCOriginalUnicastNPDU(uint 16 'bvlcLength')
[simple NPDU('bvlcLength - 4') 'npdu']
]
['0x0B' BVLCOriginalBroadcastNPDU [uint 16 'bvlcLength']
[simple NPDU 'npdu' ['bvlcLength - 4']]
['0x0B' BVLCOriginalBroadcastNPDU(uint 16 'bvlcLength')
[simple NPDU('bvlcLength - 4') 'npdu']
]
['0x0C' BVLCSecureBVLL
]
]
]

[type 'NPDU' [uint 16 'npduLength']
[type 'NPDU'(uint 16 'npduLength')
[simple uint 8 'protocolVersionNumber']
[simple bit 'messageTypeFieldPresent']
[reserved uint 1 '0']
Expand All @@ -72,27 +72,27 @@
[optional uint 8 'sourceLength' 'sourceSpecified']
[array uint 8 'sourceAddress' count 'sourceSpecified ? sourceLength : 0']
[optional uint 8 'hopCount' 'destinationSpecified']
[optional NLM 'nlm' 'messageTypeFieldPresent' ['npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))']]
[optional APDU 'apdu' '!messageTypeFieldPresent' ['npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))']]
[optional NLM('npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))') 'nlm' 'messageTypeFieldPresent' ]
[optional APDU('npduLength - (2 + (sourceSpecified ? 3 + sourceLength : 0) + (destinationSpecified ? 3 + destinationLength: 0) + ((destinationSpecified || sourceSpecified) ? 1 : 0))') 'apdu' '!messageTypeFieldPresent' ]
]

[discriminatedType 'NLM' [uint 16 'apduLength']
[discriminatedType 'NLM'(uint 16 'apduLength')
[discriminator uint 8 'messageType']
[optional uint 16 'vendorId' '(messageType >= 128) && (messageType <= 255)']
[typeSwitch 'messageType'
['0x0' NLMWhoIsRouterToNetwork [uint 16 'apduLength', uint 8 'messageType']
['0x0' NLMWhoIsRouterToNetwork(uint 16 'apduLength', uint 8 'messageType')
[array uint 16 'destinationNetworkAddress' length 'apduLength - (((messageType >= 128) && (messageType <= 255)) ? 3 : 1)']
]
['0x1' NLMIAmRouterToNetwork [uint 16 'apduLength', uint 8 'messageType']
['0x1' NLMIAmRouterToNetwork(uint 16 'apduLength', uint 8 'messageType')
[array uint 16 'destinationNetworkAddress' length 'apduLength - (((messageType >= 128) && (messageType <= 255)) ? 3 : 1)']
]
]
]

[discriminatedType 'APDU' [uint 16 'apduLength']
[discriminatedType 'APDU'(uint 16 'apduLength')
[discriminator uint 4 'apduType']
[typeSwitch 'apduType'
['0x0' APDUConfirmedRequest [uint 16 'apduLength']
['0x0' APDUConfirmedRequest(uint 16 'apduLength')
[simple bit 'segmentedMessage' ]
[simple bit 'moreFollows' ]
[simple bit 'segmentedResponseAccepted' ]
Expand All @@ -102,11 +102,11 @@
[simple uint 8 'invokeId' ]
[optional uint 8 'sequenceNumber' 'segmentedMessage']
[optional uint 8 'proposedWindowSize' 'segmentedMessage']
[simple BACnetConfirmedServiceRequest 'serviceRequest' ['apduLength - (3 + (segmentedMessage ? 2 : 0))']]
[simple BACnetConfirmedServiceRequest('apduLength - (3 + (segmentedMessage ? 2 : 0))') 'serviceRequest']
]
['0x1' APDUUnconfirmedRequest [uint 16 'apduLength']
['0x1' APDUUnconfirmedRequest(uint 16 'apduLength')
[reserved uint 4 '0' ]
[simple BACnetUnconfirmedServiceRequest 'serviceRequest' ['apduLength - 1']]
[simple BACnetUnconfirmedServiceRequest('apduLength - 1') 'serviceRequest']
]
['0x2' APDUSimpleAck
[reserved uint 4 '0' ]
Expand Down Expand Up @@ -149,12 +149,12 @@
]
]

[discriminatedType 'BACnetConfirmedServiceRequest' [uint 16 'len']
[discriminatedType 'BACnetConfirmedServiceRequest'(uint 16 'len')
[discriminator uint 8 'serviceChoice']
[typeSwitch 'serviceChoice'
['0x00' BACnetConfirmedServiceRequestAcknowledgeAlarm
]
['0x01' BACnetConfirmedServiceRequestConfirmedCOVNotification [uint 16 'len']
['0x01' BACnetConfirmedServiceRequestConfirmedCOVNotification(uint 16 'len')
[const uint 8 'subscriberProcessIdentifierHeader' '0x09' ]
[simple uint 8 'subscriberProcessIdentifier' ]
[const uint 8 'monitoredObjectIdentifierHeader' '0x1C' ]
Expand Down Expand Up @@ -212,7 +212,7 @@
]
['0x0E' BACnetConfirmedServiceRequestReadPropertyMultiple
]
['0x0F' BACnetConfirmedServiceRequestWriteProperty [uint 16 'len']
['0x0F' BACnetConfirmedServiceRequestWriteProperty(uint 16 'len')
[const uint 8 'objectIdentifierHeader' '0x0C' ]
[simple uint 10 'objectType' ]
[simple uint 22 'objectInstanceNumber' ]
Expand Down Expand Up @@ -267,7 +267,7 @@
]
]

[discriminatedType 'BACnetUnconfirmedServiceRequest' [uint 16 'len']
[discriminatedType 'BACnetUnconfirmedServiceRequest'(uint 16 'len')
[discriminator uint 8 'serviceChoice']
[typeSwitch 'serviceChoice'
['0x00' BACnetUnconfirmedServiceRequestIAm
Expand All @@ -288,7 +288,7 @@
]
['0x03' BACnetUnconfirmedServiceRequestUnconfirmedEventNotification
]
['0x04' BACnetUnconfirmedServiceRequestUnconfirmedPrivateTransfer [uint 16 'len']
['0x04' BACnetUnconfirmedServiceRequestUnconfirmedPrivateTransfer(uint 16 'len')
[const uint 8 'vendorIdHeader' '0x09']
[simple uint 8 'vendorId']
[const uint 8 'serviceNumberHeader' '0x1A']
Expand All @@ -302,10 +302,10 @@
['0x06' BACnetUnconfirmedServiceRequestTimeSynchronization
]
['0x07' BACnetUnconfirmedServiceRequestWhoHas
[optional BACnetComplexTagUnsignedInteger ['0', 'BACnetDataType.UNSIGNED_INTEGER' ] 'deviceInstanceRangeLowLimit' ]
[optional BACnetComplexTagUnsignedInteger ['1', 'BACnetDataType.UNSIGNED_INTEGER' ] 'deviceInstanceRangeHighLimit' 'deviceInstanceRangeLowLimit != null' ]
[optional BACnetComplexTagOctetString ['2', 'BACnetDataType.OCTET_STRING' ] 'objectIdentifier' ]
[optional BACnetComplexTagOctetString ['3', 'BACnetDataType.OCTET_STRING' ] 'objectName' 'objectIdentifier == null' ]
[optional BACnetComplexTagUnsignedInteger('0', 'BACnetDataType.UNSIGNED_INTEGER') 'deviceInstanceRangeLowLimit' ]
[optional BACnetComplexTagUnsignedInteger('1', 'BACnetDataType.UNSIGNED_INTEGER') 'deviceInstanceRangeHighLimit' 'deviceInstanceRangeLowLimit != null' ]
[optional BACnetComplexTagOctetString('2', 'BACnetDataType.OCTET_STRING') 'objectIdentifier' ]
[optional BACnetComplexTagOctetString('3', 'BACnetDataType.OCTET_STRING') 'objectName' 'objectIdentifier == null' ]
]
['0x08' BACnetUnconfirmedServiceRequestWhoIs
// TODO: here we need proper bacnet tags (like a discriminator etc... see line 494 BACnetTag)
Expand All @@ -325,7 +325,7 @@
]
]
[discriminatedType 'BACnetComplexTag' [uint 4 'tagNumberArgument', BACnetDataType 'dataType']
[discriminatedType 'BACnetComplexTag'(uint 4 'tagNumberArgument', BACnetDataType 'dataType')
[assert uint 4 'tagNumber' 'tagNumberArgument' ]
[const TagClass 'tagClass' 'TagClass.CONTEXT_SPECIFIC_TAGS' ]
[simple uint 3 'lengthValueType' ]
Expand All @@ -341,30 +341,30 @@
]
['BOOLEAN' BACnetComplexTagBoolean
]
['UNSIGNED_INTEGER' BACnetComplexTagUnsignedInteger [uint 3 'lengthValueType', uint 8 'extLength']
['UNSIGNED_INTEGER' BACnetComplexTagUnsignedInteger(uint 3 'lengthValueType', uint 8 'extLength')
[array int 8 'data' length '(lengthValueType == 5) ? extLength : lengthValueType']
]
['SIGNED_INTEGER' BACnetComplexTagSignedInteger [uint 3 'lengthValueType', uint 8 'extLength']
['SIGNED_INTEGER' BACnetComplexTagSignedInteger(uint 3 'lengthValueType', uint 8 'extLength')
[array int 8 'data' length '(lengthValueType == 5) ? extLength : lengthValueType']
]
['REAL' BACnetComplexTagReal [uint 3 'lengthValueType', uint 8 'extLength']
['REAL' BACnetComplexTagReal(uint 3 'lengthValueType', uint 8 'extLength')
[simple float 32 'value']
]
['DOUBLE' BACnetComplexTagDouble [uint 3 'lengthValueType', uint 8 'extLength']
['DOUBLE' BACnetComplexTagDouble(uint 3 'lengthValueType', uint 8 'extLength')
[simple float 64 'value']
]
['OCTET_STRING' BACnetComplexTagOctetString [uint 32 'actualLength']
['OCTET_STRING' BACnetComplexTagOctetString(uint 32 'actualLength')
// TODO: The reader expects int but uint32 get's mapped to long so even uint32 would easily overflow...
[virtual uint 16 'actualLengthInBit' 'actualLength * 8']
[simple vstring 'actualLengthInBit' 'theString' encoding='ASCII']
]
['CHARACTER_STRING' BACnetComplexTagCharacterString
]
['BIT_STRING' BACnetComplexTagBitString [uint 3 'lengthValueType', uint 8 'extLength']
['BIT_STRING' BACnetComplexTagBitString(uint 3 'lengthValueType', uint 8 'extLength')
[simple uint 8 'unusedBits']
[array int 8 'data' length '(lengthValueType == 5) ? (extLength - 1) : (lengthValueType - 1)']
]
['ENUMERATED' BACnetComplexTagEnumerated [uint 3 'lengthValueType', uint 8 'extLength']
['ENUMERATED' BACnetComplexTagEnumerated(uint 3 'lengthValueType', uint 8 'extLength')
[array int 8 'data' length '(lengthValueType == 5) ? extLength : lengthValueType']
]
['DATE' BACnetComplexTagDate
Expand Down
54 changes: 27 additions & 27 deletions protocols/canopen/src/main/resources/protocols/can/canopen.mspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
* under the License.
*/

[enum uint 4 'CANOpenService' [uint 8 'min', uint 8 'max', bit 'pdo']
['0b0000' NMT ['0', '0' , 'false' ] ]
['0b0001' SYNC ['0x80', '0x80' , 'false' ] ]
['0b0001' EMCY ['0x81', '0xFF' , 'false' ] ]
['0b0010' TIME ['0x100', '0x100', 'false' ] ]
['0b0011' TRANSMIT_PDO_1 ['0x180', '0x1FF', 'true' ] ]
['0b0100' RECEIVE_PDO_1 ['0x200', '0x27F', 'true' ] ]
['0b0101' TRANSMIT_PDO_2 ['0x280', '0x2FF', 'true' ] ]
['0b0110' RECEIVE_PDO_2 ['0x300', '0x37F', 'true' ] ]
['0b0111' TRANSMIT_PDO_3 ['0x380', '0x3FF', 'true' ] ]
['0b1000' RECEIVE_PDO_3 ['0x400', '0x47F', 'true' ] ]
['0b1001' TRANSMIT_PDO_4 ['0x480', '0x4FF', 'true' ] ]
['0b1010' RECEIVE_PDO_4 ['0x500', '0x57F', 'true' ] ]
['0b1011' TRANSMIT_SDO ['0x580', '0x5FF', 'false' ] ]
['0b1100' RECEIVE_SDO ['0x600', '0x67F', 'false' ] ]
['0b1110' HEARTBEAT ['0x700', '0x77F', 'false' ] ]
[enum uint 4 'CANOpenService'(uint 8 'min', uint 8 'max', bit 'pdo')
['0b0000' NMT ('0', '0' , 'false') ]
['0b0001' SYNC ('0x80', '0x80' , 'false') ]
['0b0001' EMCY ('0x81', '0xFF' , 'false') ]
['0b0010' TIME ('0x100', '0x100', 'false') ]
['0b0011' TRANSMIT_PDO_1 ('0x180', '0x1FF', 'true' ) ]
['0b0100' RECEIVE_PDO_1 ('0x200', '0x27F', 'true' ) ]
['0b0101' TRANSMIT_PDO_2 ('0x280', '0x2FF', 'true' ) ]
['0b0110' RECEIVE_PDO_2 ('0x300', '0x37F', 'true' ) ]
['0b0111' TRANSMIT_PDO_3 ('0x380', '0x3FF', 'true' ) ]
['0b1000' RECEIVE_PDO_3 ('0x400', '0x47F', 'true' ) ]
['0b1001' TRANSMIT_PDO_4 ('0x480', '0x4FF', 'true' ) ]
['0b1010' RECEIVE_PDO_4 ('0x500', '0x57F', 'true' ) ]
['0b1011' TRANSMIT_SDO ('0x580', '0x5FF', 'false') ]
['0b1100' RECEIVE_SDO ('0x600', '0x67F', 'false') ]
['0b1110' HEARTBEAT ('0x700', '0x77F', 'false') ]
]

[enum uint 8 'NMTStateRequest'
Expand All @@ -50,7 +50,7 @@
['0x7f' PRE_OPERATIONAL]
]

[discriminatedType 'CANOpenPayload' [CANOpenService 'service']
[discriminatedType 'CANOpenPayload'(CANOpenService 'service')
[typeSwitch 'service'
['NMT' CANOpenNetworkPayload
[enum NMTStateRequest 'request']
Expand All @@ -61,36 +61,36 @@
[simple CANOpenTime 'timeOfDay']
]
['RECEIVE_PDO_1' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['1', 'true']]
[simple CANOpenPDO('1', 'true') 'pdo']
]
['TRANSMIT_PDO_1' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['1', 'false']]
[simple CANOpenPDO('1', 'false') 'pdo']
]
['RECEIVE_PDO_2' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['2', 'true']]
[simple CANOpenPDO('2', 'true') 'pdo']
]
['TRANSMIT_PDO_2' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['1', 'false']]
[simple CANOpenPDO('1', 'false') 'pdo']
]
['RECEIVE_PDO_3' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['3', 'true']]
[simple CANOpenPDO('3', 'true') 'pdo']
]
['TRANSMIT_PDO_3' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['1', 'false']]
[simple CANOpenPDO('1', 'false') 'pdo']
]
['RECEIVE_PDO_4' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['4', 'true']]
[simple CANOpenPDO('4', 'true') 'pdo']
]
['TRANSMIT_PDO_4' CANOpenPDOPayload
[simple CANOpenPDO 'pdo' ['1', 'false']]
[simple CANOpenPDO('1', 'false') 'pdo']
]
['RECEIVE_SDO' CANOpenSDORequest
[enum SDORequestCommand 'command']
[simple SDORequest 'request' ['command']]
[simple SDORequest('command') 'request']
]
['TRANSMIT_SDO' CANOpenSDOResponse
[enum SDOResponseCommand 'command']
[simple SDOResponse 'response' ['command']]
[simple SDOResponse('command') 'response']
]
['HEARTBEAT' CANOpenHeartbeatPayload
[enum NMTState 'state']
Expand Down
38 changes: 19 additions & 19 deletions protocols/eip/src/main/resources/protocols/eip/eip.mspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
]
['0x0066' EipDisconnectRequest
]
['0x006F' CipRRData [uint 16 'len']
['0x006F' CipRRData(uint 16 'len')
[reserved uint 32 '0x00000000']
[reserved uint 16 '0x0000']
[simple CipExchange 'exchange' ['len-6']]
Expand All @@ -50,15 +50,15 @@
[simple CipService 'service' ['exchangeLen - 10'] ]
]
[discriminatedType 'CipService' [uint 16 'serviceLen']
[discriminatedType 'CipService'(uint 16 'serviceLen')
[discriminator uint 8 'service']
[typeSwitch 'service'
['0x4C' CipReadRequest
[simple int 8 'RequestPathSize']
[array int 8 'tag' length '(RequestPathSize*2)']
[simple uint 16 'elementNb']
]
['0xCC' CipReadResponse [uint 16 'serviceLen']
['0xCC' CipReadResponse(uint 16 'serviceLen')
[reserved uint 8 '0x00']
[simple uint 8 'status']
[simple uint 8 'extStatus']
Expand All @@ -77,12 +77,12 @@
[simple uint 8 'status']
[simple uint 8 'extStatus']
]
['0x0A' MultipleServiceRequest [uint 16 'serviceLen']
['0x0A' MultipleServiceRequest(uint 16 'serviceLen')
[const int 8 'RequestPathSize' '0x02']
[const uint 32 'RequestPath' '0x01240220'] //Logical Segment: Class(0x20) 0x02, Instance(0x24) 01 (Message Router)
[simple Services 'data' ['serviceLen - 6 '] ]
[simple Services('serviceLen - 6 ') 'data' ]
]
['0x8A' MultipleServiceResponse [uint 16 'serviceLen']
['0x8A' MultipleServiceResponse(uint 16 'serviceLen')
[reserved uint 8 '0x0']
[simple uint 8 'status']
[simple uint 8 'extStatus']
Expand All @@ -98,7 +98,7 @@
[reserved uint 8 '0x01'] // setRequestPathInstance
[reserved uint 16 '0x9D05'] //Timeout 5s
[implicit uint 16 'messageSize' 'lengthInBytes - 10 - 4'] //subtract above and routing
[simple CipService 'unconnectedService' ['messageSize'] ]
[simple CipService('messageSize') 'unconnectedService' ]
[const uint 16 'route' '0x0001']
[simple int 8 'backPlane']
[simple int 8 'slot']
Expand All @@ -112,19 +112,19 @@
[array CipService 'services' count 'serviceNb' ['servicesLen/serviceNb'] ]
]

[enum uint 16 'CIPDataTypeCode' [uint 8 'size']
['0X00C1' BOOL ['1']]
['0X00C2' SINT ['1']]
['0X00C3' INT ['2']]
['0X00C4' DINT ['4']]
['0X00C5' LINT ['8']]
['0X00CA' REAL ['4']]
['0X00D3' DWORD ['4']]
['0X02A0' STRUCTURED ['88']]
['0X02A0' STRING ['88']]
['0X02A0' STRING36 ['40']]
[enum uint 16 'CIPDataTypeCode'(uint 8 'size')
['0X00C1' BOOL ('1')]
['0X00C2' SINT ('1')]
['0X00C3' INT ('2')]
['0X00C4' DINT ('4')]
['0X00C5' LINT ('8')]
['0X00CA' REAL ('4')]
['0X00D3' DWORD ('4')]
['0X02A0' STRUCTURED ('88')]
['0X02A0' STRING ('88')]
['0X02A0' STRING36 ('40')]
//TODO: -1 is not a valid value for uint
//['-1' UNKNOWN ['-1']]
//['-1' UNKNOWN ('-1')]
]

[enum uint 16 'EiPCommand'
Expand Down
Loading

0 comments on commit a17dda1

Please sign in to comment.