| /* Copyright (c) 2000-2019 Ericsson Telecom AB |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| * |
| * Contributors: |
| * Michael Josenhans |
| ******************************************************************************/ |
| |
| module J1939 { |
| import from General_Types all; |
| |
| external function f_encode_J1939_name(in J1939_NAME pdu) return octetstring |
| with { extension "prototype(convert) encode(RAW)" } |
| external function f_decode_J1939_name(in octetstring data) return J1939_NAME |
| with { extension "prototype(convert) decode(RAW)" } |
| |
| external function f_encode_J1939_name_record(in J1939_NAME_RECORD pdu) return octetstring |
| with { extension "prototype(convert) encode(RAW)" } |
| external function f_decode_J1939_name_record(in octetstring data) return J1939_NAME_RECORD |
| with { extension "prototype(convert) decode(RAW)" } |
| |
| external function f_encode_J1939_name_record_reverse_byte_order(in J1939_NAME_RECORD_REVERSE_BYTE_ENCODING pdu) return octetstring |
| with { extension "prototype(convert) encode(RAW)" } |
| external function f_decode_J1939_name_record_reverse_byte_order(in octetstring data) return J1939_NAME_RECORD_REVERSE_BYTE_ENCODING |
| with { extension "prototype(convert) decode(RAW)" } |
| |
| const octetstring J1939_MAX_UNICAST_ADDR := 'FD'O |
| const octetstring J1939_IDLE_ADDR := 'FE'O |
| const octetstring J1939_NO_ADDR := 'FF'O /* == broadcast or no addr */ |
| const J1939_NAME J1939_NO_NAME := '0000000000000000'O |
| const octetstring J1939_PGN_REQUEST := '00ea00'O /* Request PG */ |
| const octetstring J1939_PGN_ADDRESS_CLAIMED := '00ee00'O /* Address Claimed */ |
| const octetstring J1939_PGN_ADDRESS_COMMANDED := '00fed8'O /* Commanded Address */ |
| const octetstring J1939_PGN_PDU1_MAX := '03ff00'O |
| const octetstring J1939_PGN_MAX := '03ffff'O |
| const octetstring J1939_NO_PGN := '040000'O |
| |
| const octetstring c_pgn_VT2ECU := '00E600'O // VT to ECU |
| const octetstring c_pgn_ECU2VT := '00E700'O // ECU to VT |
| |
| |
| |
| |
| type OCT3 J1939_PGN // max 0x3ffff |
| type OCT8 J1939_NAME with {variant "BYTEORDER(last)"} |
| type OCT1 J1939_ADDR |
| |
| type record J1939_NAME_RECORD{ |
| J1939_ARBITRARY_ADDRESS_BIT arbitraryAddresssBit, // selfConfigurableAddressValue |
| J1939_INDUSTRY_GROUP industryGroup, // deviceClassInstanceValue |
| J1939_VEHICLE_SYSTEM_INSTANCE vehicleSystemInstance, // deviceClassInstanceValue |
| J1939_VEHICLE_SYSTEM vehicleSystem, |
| J1939_RESERVED reserved, |
| J1939_FUNCTION function_, |
| J1939_FUNCTION_INSTANCE functionInstance, |
| J1939_ECU_INSTANCE ecuInstance, |
| J1939_MANUFACTURER_CODE manufacturerCode, |
| J1939_IDENTITY_NUMBER identityNumber |
| } with { variant "FIELDORDER(msb)" |
| variant (identityNumber) "BYTEORDER(last)" |
| variant (manufacturerCode) "BYTEORDER(last)" |
| } |
| |
| type record J1939_NAME_RECORD_REVERSE_BYTE_ENCODING{ |
| J1939_IDENTITY_NUMBER identityNumber, |
| J1939_MANUFACTURER_CODE manufacturerCode, |
| J1939_ECU_INSTANCE ecuInstance, |
| J1939_FUNCTION_INSTANCE functionInstance, |
| J1939_FUNCTION function_, |
| J1939_RESERVED reserved, |
| J1939_VEHICLE_SYSTEM vehicleSystem, |
| J1939_VEHICLE_SYSTEM_INSTANCE vehicleSystemInstance, // deviceClassInstanceValue |
| J1939_INDUSTRY_GROUP industryGroup, // deviceClassInstanceValue |
| J1939_ARBITRARY_ADDRESS_BIT arbitraryAddresssBit // selfConfigurableAddressValue |
| } with { variant "FIELDORDER(lsb)" /* it has no effect here, added for visibility only */ |
| |
| variant (identityNumber) "BYTEORDER(first)" |
| variant (manufacturerCode) "BYTEORDER(first)" |
| /* the following variants are not needed: |
| variant (ecuInstance) "BYTEORDER(first)" |
| variant (functionInstance) "BYTEORDER(first)" |
| variant (function_) "BYTEORDER(first)" |
| variant (reserved) "BYTEORDER(first)" |
| variant (vehicleSystem) "BYTEORDER(first)" |
| variant (vehicleSystemInstance) "BYTEORDER(first)" |
| variant (industryGroup) "BYTEORDER(first)" |
| variant (arbitraryAddresssBit) "BYTEORDER(first)" |
| */ |
| } |
| |
| type INT1BIT J1939_ARBITRARY_ADDRESS_BIT |
| type INT3BIT J1939_INDUSTRY_GROUP |
| type INT4BIT J1939_VEHICLE_SYSTEM_INSTANCE |
| type INT7BIT J1939_VEHICLE_SYSTEM |
| type INT1BIT J1939_RESERVED |
| type INT8BIT J1939_FUNCTION |
| type INT5BIT J1939_FUNCTION_INSTANCE |
| type INT3BIT J1939_ECU_INSTANCE |
| type INT11BIT J1939_MANUFACTURER_CODE |
| type INT21BIT J1939_IDENTITY_NUMBER |
| |
| type integer INT1BIT (0..1) with { variant "FIELDLENGTH(1)"} // 2^1-1 |
| type integer INT3BIT (0..7) with { variant "FIELDLENGTH(3)"} // 2^3-1 |
| type integer INT4BIT (0..15) with { variant "FIELDLENGTH(4)"} // 2^4-1 |
| type integer INT5BIT (0..31) with { variant "FIELDLENGTH(5)"} // 2^5-1 |
| type integer INT7BIT (0..127) with { variant "FIELDLENGTH(7)"} // 2^7-1 |
| type integer INT8BIT (0..255) with { variant "FIELDLENGTH(8)"} // 2^8-1 |
| type integer INT11BIT (0..2047) with { variant "FIELDLENGTH(11),BYTEORDER(last)"} // 2^11-1 |
| type integer INT21BIT (0..2097151) with { variant "FIELDLENGTH(21),BYTEORDER(last)"} // 2^21-1 |
| |
| type integer J1939_Priority (0..7) |
| |
| type record J1939_hdr{ |
| J1939_NAME name optional, |
| // pgn: |
| // * 8 bit: PS in PDU2 case, else 0 |
| // * 8 bit: PF |
| // * 1 bit: DP |
| // * 1 bit: reserved |
| J1939_PGN pgn optional, |
| // * 1 byte address * |
| J1939_ADDR addr optional |
| } with { variant "" } |
| |
| } with { encode "RAW" } |