Commit 403f5b67 authored by Elemer Lelik's avatar Elemer Lelik
Browse files

significant update to Isobus covering bug fixes and functionality

parent 77a50aac
......@@ -11,12 +11,11 @@
// File: Isobus.ttcn
// Description: Encoder / Decoder for Isobus message frames
//
// Revision R1A
module Isobus {
import from General_Types all
import from Can all
import from IsobusMessageTypes all
import from IsobusCMMessageTypes all
import from IsobusNMMessageTypes all
import from IsobusVTMessageTypes all
......@@ -75,14 +74,17 @@ type record J1939mod { // Error & RTR Frames are not considered here
type union AnyIsoBusPdu {
TopLevelMessage_VT2ECU_PDU vt2ecu, // Message Virtual Terminal (VT) to ECU
TopLevelMessage_ECU2VT_PDU ecu2vt, // Message ECU to Virtual Terminal (VT)
ETP_DT etp_dt, // extended TP data transfer
ETP_CM etp_cm, // extended TP connection management
VT2ECU vt2ecu, // Message Virtual Terminal (VT) to ECU
ECU2VT ecu2vt, // Message ECU to Virtual Terminal (VT)
RequestForAddressClaimed requestForAddressClaimed,
TP_DT tp_dt,
TP_CM tp_cm,
CannotClaimSourceAddress cannotClaimSourceAddress,
AddressClaimed addressClaimed,
CommandedAddress commandedAddress
TP_DT tp_dt, // TP data transfer
TP_CM tp_cm, // TP connection management
NetworkMessage networkMessage, // Network Message according ISO 11873-4
CannotClaimSourceAddress cannotClaimSourceAddress,
AddressClaimed addressClaimed,
CommandedAddress commandedAddress
// other upper layer isobus protocols like Task Comtroller are added here ...
}
with { variant "" }
......@@ -97,17 +99,22 @@ type record CAN_frame_j1939mod {
J1939mod can_j1939,
AnyIsoBusPdu can_pdu
}with {
variant (can_pdu) "CROSSTAG(
variant (can_pdu) "CROSSTAG(
etp_dt, can_j1939.comp = 'C70000'O; //199
etp_cm, can_j1939.comp = 'C80000'O; //200
vt2ecu, can_j1939.comp = 'E60000'O; //230
ecu2vt, can_j1939.comp = 'E70000'O; //231
requestForAddressClaimed, can_j1939.comp = 'EA0000'O; //234
tp_dt, can_j1939.comp = 'EB0000'O;
tp_cm, can_j1939.comp = 'EC0000'O;
cannotClaimSourceAddress, can_j1939.comp = 'EEFFFE'O; //238 all and conjuction needed!!!!!!
tp_dt, can_j1939.comp = 'EB0000'O; //235
tp_cm, can_j1939.comp = 'EC0000'O; //236
networkMessage, can_j1939.comp = 'ED0000'O; //237
cannotClaimSourceAddress, can_j1939.comp = 'EEFFFE'O; //238 all and conjuction needed!!!!!!
addressClaimed, can_j1939.comp = 'EEFF00'O; //238 all and conjuction needed!!!!!!
commandedAddress, can_j1939.comp = 'FED800'O)" //254 all and conjuction needed!!!!!!
}
//---------------------------------------------------------------------------------------
function j1939frame2can(in CAN_frame_j1939 p_can_frame_j1939, in Priority p_priority, in DestinationAddress p_da, in SourceAddress p_sa) return CAN_frame {
//---------------------------------------------------------------------------------------
......@@ -125,22 +132,43 @@ function pdu1_j1939id2canid(in J1939 p_j1939, in Priority p_priority, in Destina
((p_j1939.res) << 25) or4b (int2bit(bit2int(p_priority), 32) << 26))
return v_can_id
}
/*
function j1939id2canid(in J1939 p_j1939) return CAN_id{
var CAN_id v_can_id
v_can_id := (p_j1939.sa << 0) or4b (p_j1939.ps << 8) or4b (p_j1939.pf << 16) or4b bit2oct(p_j1939.dp << 24) or4b
bit2oct(p_j1939.res << 25) or4b bit2oct(p_j1939.prio << 26)
return v_can_id
}
*/
function j1939id2canid(in J1939 p_j1939) return CAN_id{
var CAN_id v_can_id
v_can_id := int2oct(
oct2int(p_j1939.sa) + oct2int(p_j1939.ps)*256 + oct2int(p_j1939.pf) * 256 * 256 +
bit2int(p_j1939.dp) * 256 * 256 * 256 + bit2int(p_j1939.res) * 256 * 256 * 256 * 2 +
bit2int(p_j1939.prio) * 256 * 256 * 256 * 2 * 2,
4 )
return v_can_id
}
//---------------------------------------------------------------------------------------
function can2j1939frame(CAN_frame p_can_frame) return CAN_frame_j1939 {
//---------------------------------------------------------------------------------------
var CAN_frame_j1939 v_can_frame_j1939
log("can_id", p_can_frame.can_id)
log("can_pdu", p_can_frame.can_pdu)
//log("can_id", p_can_frame.can_id)
//log("can_pdu", p_can_frame.can_pdu)
v_can_frame_j1939:=f_decode_CAN_frame_j1939(p_can_frame.can_id& p_can_frame.can_pdu)
log("Higher layer octet pdustring: ", v_can_frame_j1939)
//log("Higher layer octet pdustring: ", v_can_frame_j1939)
return v_can_frame_j1939
}
function canid2j1939(in CAN_id p_can_id) return J1939 {
//---------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------
var bitstring v_can_id_bitstring:= oct2bit(p_can_id)
var J1939 v_j1939
......@@ -151,8 +179,8 @@ function canid2j1939(in CAN_id p_can_id) return J1939 {
v_j1939.pf :=p_can_id[1];//(p_can_id and4b ISOBUS_PDUFORMAT_MASK) >> 2 // shift 16 bits = 2 octets
v_j1939.ps :=p_can_id[2];// (p_can_id and4b ISOBUS_PDUSPECIFIC_MASK) >> 1 // shift 8 bits = 1 octet
v_j1939.sa :=p_can_id[3];//(p_can_id and4b ISOBUS_SOURCEADDRESS_MASK)
return v_j1939
return v_j1939
}
//********************************************************************************-
......@@ -290,7 +318,6 @@ function f_encode_CAN_frame_j1939(in CAN_frame_j1939 pdu) return octetstring
function f_decode_CAN_frame_j1939(in octetstring data) return CAN_frame_j1939
//---------------------------------------------------------------------------
{
return f_map_mod2frame(decode_CAN_frame_j1939mod(f_insert_aux_hdr(data)))
......@@ -298,3 +325,4 @@ function f_decode_CAN_frame_j1939(in octetstring data) return CAN_frame_j1939
} with { encode "RAW" }
/* Copyright (c) 2010, 2016 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Michael Josenhans
******************************************************************************/
module IsobusCMMessageTypes {
import from General_Types all
import from IsobusMessageTypes all
type integer SEQ_NO (1..255) with { variant "FIELDLENGTH(8)" }
type integer NUMBER_OF_PACKETS (1..255) with { variant "FIELDLENGTH(8)" }
type OCT1 Ctrl
type record RequestToSend{
Ctrl ctrl ('10'O),
INT2 msgSizeInByte,
INT1 totalNumberOfPackets,
INT1 maxNoOfPacketsInResponseToCTS,
PGN pgnOfMultiPacketMessage
Ctrl ctrl ('10'O),
INT2 msgSizeInBytes,
NUMBER_OF_PACKETS totalNumberOfPackets,
INT1 maxNoOfPacketsInResponseToCTS,
PGN pgnOfMultiPacketMessage
} with { variant "" };
type record ClearToSend{
Ctrl ctrl ('11'O),
INT1 totalNumberOfPackets,
INT1 nextPacketNumber,
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
Ctrl ctrl ('11'O),
NUMBER_OF_PACKETS totalNumberOfPackets,
INT1 nextPacketNumber,
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
} with { variant "" };
type record EndOfMessageAcknowledgement{
Ctrl ctrl ('13'O),
INT2 msgSizeInByte,
INT1 totalNumberOfPackets,
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
Ctrl ctrl ('13'O),
INT2 msgSizeInByte,
NUMBER_OF_PACKETS totalNumberOfPackets,
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
} with { variant "" };
type enumerated e_ConnectionAbort_AbortReason {
alreadyInOneOrMoreConnectionManagedSessionsAndCannotSupportAnother (1),
systemResourcesWereNeededForAnotherTaskSoThisConnectionManagedSessionWasTerminated (2),
aTimeoutOccurredAndThisIsTheConnectionAbortToCloseTheSession (3),
cts_MessagesReceivedWhenDataTransferIsInProgress (4),
maximumRetransmitRequestLimitReached (5),
unexpectedDataTransferPacket (6),
badSequenceNumber (7),
duplicateSequenceNumber (8),
iso_11783_7_error_code_251 (251),
iso_11783_7_error_code_252 (252),
iso_11783_7_error_code_253 (253),
iso_11783_7_error_code_254 (254),
iso_11783_7_error_code_255 (255)}
with {variant "PADDING(octet)" };
type record ConnectionAbort{
Ctrl ctrl ('FF'O),
OCT1 connectionAbortReason,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
Ctrl ctrl ('FF'O),
e_ConnectionAbort_AbortReason connectionAbortReason,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
} with { variant "" };
type record BroadcastAnnonce{
Ctrl ctrl ('20'O),
INT2 msgSizeInByte,
INT1 totalNumberOfPackets,
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
type record BroadcastAnnounce{
Ctrl ctrl ('20'O),
INT2 msgSizeInByte,
NUMBER_OF_PACKETS totalNumberOfPackets,
OCT1 reserved5 ('FF'O),
PGN pgnOfMultiPacketMessage
} with { variant "" };
type union TP_CM
......@@ -63,11 +71,11 @@ type union TP_CM
RequestToSend requestToSend,
ClearToSend clearToSend,
EndOfMessageAcknowledgement endOfMessageAcknowledgement,
BroadcastAnnonce broadcastAnnounce,
BroadcastAnnounce broadcastAnnounce,
ConnectionAbort connectionAbort
}
with {variant "TAG (
// put all ECU2VT request messages here
// put all TP_CM request messages here
requestToSend, ctrl = '10'O;
clearToSend, ctrl = '11'O;
endOfMessageAcknowledgement, ctrl = '13'O;
......@@ -75,11 +83,101 @@ with {variant "TAG (
connectionAbort, ctrl = 'FF'O;
) "
}
// ETP_CM
type integer ETP_MSG_SIZE (1786..117440505)
with { variant "FIELDLENGTH(32)" };
type record ExtendedMessageRequestToSend{
Ctrl ctrl ('20'O),
ETP_MSG_SIZE msgSizeInBytes,
PGN pgnOfExtendedPacketedMessage
} with { variant "" };
type integer ETP_NextPacketNumberToSend (0..16777215)
with { variant "FIELDLENGTH(32)" };
type record ExtendedMessageClearToSend{
Ctrl ctrl ('21'O),
INT1 NumberOfPacketsToSend,
ETP_NextPacketNumberToSend nextPacketNumberToSend,
PGN pgnOfExtendedPacketedMessage
} with { variant "" };
type integer ETP_NoPacketForOffset (1..255)
with { variant "FIELDLENGTH(8)" };
type record ExtendedMessageDataPacketOffset{
Ctrl ctrl ('22'O),
ETP_NoPacketForOffset numberOfPacketsToWhichToApplyTheOffset,
NUMBER_OF_PACKETS totalNumberOfPackets,
ETP_NextPacketNumberToSend dataPacketOffset,
PGN pgnOfExtendedPacketedMessage
} with { variant "" };
type record ExtendedMessageEndOfMessageAcknowledgement{
Ctrl ctrl ('23'O),
ETP_MSG_SIZE numberOfBytesTransferred,
PGN pgnOfExtendedPacketedMessage
} with { variant "" };
type enumerated e_ETP_ConnectionAbort_AbortReason {
alreadyInOneOrMoreConnectionManagedSessionsAndCannotSupportAnother (1),
systemResourcesWereNeededForAnotherTaskSoThisConnectionManagedSessionWasTerminated (2),
aTimeoutOccurredAndThisIsTheConnectionAbortToCloseTheSession (3),
cts_MessagesReceivedWhenDataTransferIsInProgress (4),
maximumRetransmitRequestLimitReached (5),
unexpectedDataTransferPacket (6),
badSequenceNumber (7),
duplicateSequenceNumber (8),
unexpectedEDPO_Packet (9),
unexpectedEDPO_PGN (10),
edpo_numberOfPacketsIsGreaterThanCTS (11),
badEDPO_Offset (12),
unexpectedECTS_PGN (14),
ECTS_requestedPacketsExceedsMessageSize (15),
iso_11783_7_error_code_251 (251),
iso_11783_7_error_code_252 (252),
iso_11783_7_error_code_253 (253),
iso_11783_7_error_code_254 (254),
iso_11783_7_error_code_255 (255)}
with {variant "PADDING(octet)" };
type record ExtendedMessageConnectionAbort{
Ctrl ctrl ('FF'O),
e_ETP_ConnectionAbort_AbortReason connectionAbortReason,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
PGN pgnOfExtendedPacketedMessage
} with { variant "" };
type union ETP_CM
{
ExtendedMessageRequestToSend extendedMessageRequestToSend,
ExtendedMessageClearToSend extendedMessageClearToSend,
ExtendedMessageDataPacketOffset extendedMessageDataPacketOffset,
ExtendedMessageEndOfMessageAcknowledgement extendedMessageEndOfMessageAcknowledgement,
ExtendedMessageConnectionAbort extendedMessageConnectionAbort
}
with {variant "TAG (
// put all ETP_CM request messages here
extendedMessageRequestToSend, ctrl = '20'O;
extendedMessageClearToSend, ctrl = '21'O;
extendedMessageDataPacketOffset, ctrl = '22'O;
extendedMessageEndOfMessageAcknowledgement, ctrl = '23'O;
extendedMessageConnectionAbort, ctrl = 'FF'O;
) "
}
type record TP_DT{
INT1 seq_no,
OCT7 data
SEQ_NO seq_no,
OCT7 data
} with { variant "" }
type record ETP_DT{
SEQ_NO seq_no,
OCT7 data
} with { variant "" }
} with { encode "RAW" }
/* Copyright (c) 2010, 2016 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
/*
* Contributors:
* Michael Josenhans
******************************************************************************/
*/
module IsobusMessageTypes {
......@@ -14,12 +9,14 @@ module IsobusMessageTypes {
type integer INT24nb (0..16777215) with { variant "FIELDLENGTH(24), COMP(nosign), BYTEORDER(last)" };
type INT24nb PGN
type bitstring BIT21 length(21) with { variant "FIELDLENGTH(21)" };
type integer INT2 (0..65535)
with { variant "FIELDLENGTH(16)" };
type integer INT3 (0..16777215)
with { variant "FIELDLENGTH(24)" };
}
with { encode "RAW" }
/* Copyright (c) 2010, 2016 Ericsson AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
/*
* Contributors:
* Michael Josenhans
******************************************************************************/
*/
module IsobusNMMessageTypes {
......@@ -17,7 +12,38 @@ type OCT1 DestinationAddress
type OCT1 PDUFormat
type OCT1 SourceAddress
type OCT8 NAME
//type OCT8 NAME
type bitstring Priority length(6)
with {
variant "ALIGN(left)";
variant "FIELDLENGTH(6)"
}
type BIT1 SelfConfigurableAddressBits
type BIT3 IndustryGroupBits
type BIT4 DeviceClassInstanceBits
type BIT7 DeviceClassBits
type BIT1 ReservedBits
type BIT8 FunctionBits
type BIT5 FunctionInstanceBits
type BIT3 ECUInstanceBits
type BIT11 ManufacturerCodeBits
type BIT21 IdentityNumberBits
type record NAME {
SelfConfigurableAddressBits selfConfigurableAddressValue,
IndustryGroupBits industryGroupValue,
DeviceClassInstanceBits deviceClassInstanceValue,
DeviceClassBits deviceClassValue,
ReservedBits reserveValued,
FunctionBits functionValue,
FunctionInstanceBits functionInstanceValue,
ECUInstanceBits ecuInstancceValue,
ManufacturerCodeBits manufacturerCodeValue,
IdentityNumberBits identityNumberBits
} with { variant "FIELDORDER(msb)" }
type record CannotClaimSourceAddress
{
......@@ -40,4 +66,397 @@ type record CommandedAddress {
SourceAddress newSourceAddress
} with { variant "" }
// --------- NetworkMessage -------------
type INT1 Function
type record N_MFDB_Request
{
Function MsgFunction (0),
PortPair portPair,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
OCT1 reserved6 ('FF'O),
OCT1 reserved7 ('FF'O),
OCT1 reserved8 ('FF'O)
} with {variant "" };
type record N_MFDB_Response
{
Function MsgFunction (1),
PortPair portPair,
e_FilterMode filterMode,
record length (1..infinity) of PGN pgnEntries
} with {variant "" };
type record N_MFDB_Add
{
Function MsgFunction (2),
PortPair portPair,
record length (1..infinity) of PGN pgnEntries
} with {variant "" };
type record N_MFDB_Delete
{
Function MsgFunction (3),
PortPair portPair,
record length (1..infinity) of PGN pgnEntries
} with {variant "" };
type record N_MFDB_Clear
{
Function MsgFunction (4),
PortPair portPair,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
OCT1 reserved6 ('FF'O),
OCT1 reserved7 ('FF'O),
OCT1 reserved8 ('FF'O)
} with {variant "" };
type record N_MFDB_Create_Entry
{
Function MsgFunction (6),
PortPair portPair,
e_FilterMode filterMode,
record length (1..infinity) of PGN pgnEntries
} with {variant "" };
type record PGNEntry
{
INT1 maxTransferRate,
PGN pgn,
NAME name,
OCT8 nameQualifier
} with {variant "" };
type record N_MFDBNQ_Add
{
Function MsgFunction (7),
PortPair portPair,
e_FilterMode filterMode,
OCT1 reserved4 ('FF'O),
record length (1..infinity) of PGNEntry pgnEntries
} with {variant "" };
type record N_NT_Request
{
Function MsgFunction (64),
PortNibble portPair,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
OCT1 reserved6 ('FF'O),
OCT1 reserved7 ('FF'O),
OCT1 reserved8 ('FF'O)
} with {variant "" };
type record N_NT_Response
{
Function MsgFunction (65),
PortNibble portPair,
record length (1..infinity) of SourceAddress SourceAddressEntries
} with {variant "" };
type record N_NTX_Request
{
Function MsgFunction (66),
PortNibble portPair,
OCT1 reserved3 ('FF'O),
OCT1 reserved4 ('FF'O),
OCT1 reserved5 ('FF'O),
OCT1 reserved6 ('FF'O),
OCT1 reserved7 ('FF'O),
OCT1 reserved8 ('FF'O)
} with {variant "" };
type record SA_NAME_pair
{
SourceAddress sourceAddress,
NAME name
} with {variant "" };
type record N_NTX_Response
{
Function MsgFunction (67),
PortNibble portPair,
INT1 numberOfReportedPorts,
record length (1..infinity) of SA_NAME_pair sourceaddress_NAME_pairs
} with {
variant (numberOfReportedPorts) "LENGTHTO(sourceaddress_NAME_pairs)";
variant (numberOfReportedPorts) "UNIT(elements)"
}
type enumerated e_ParametricIdentifier {
requestAllParameters (0),
buffersize (1),
maximumFilterDatabaseSize (2),
numberOfFilterDatabaseEntries (3),
maximumNumberOfMessagesReceivedPerSecond (4),
maximumNumberOfMessagesForwardedPerSecond (5),
maximumNumberOfMessagesFilteredPerSecond (6),
maximumTransitDelayTime_ms (7),
averageTransitDelayTime_ms (8),
numberOfMessagesLostDueToBufferOverflow (9),
numberOfMessagesWithExcessTransitDelayTime (10),
averageNumberOfMessagesReceivedPerSecond (11),
averageNumberOfMessagesForwardedPerSecond (12),
averageNumberOfMessagesFilteredPerSecond (13),
uptimeSinceLastPowerOnReset_s (14),
numberOfPorts (15),
networkInterconnectionUnitType (16),
reserved (255) // for message padding (workaround)
}
with {variant "PADDING(octet)"}
type record N_GP_Request
{
Function MsgFunction (128),
record length (6..255) of e_ParametricIdentifier parametricIdentifiers
// Note: If total length below 8 bytes shall be padded to 8 bytes with reserved within ParametricIdentifiers
// this is the easiest way to handle it
} with {
variant "" }
// begin not used
// the following is currently not used as it is impossible to handle it with raw encoding
type OCT2 Buffersize
type OCT2 MaximumFilterDatabaseSize
type OCT2 NumberOfFilterDatabaseEntries
type OCT2 MaximumNumberOfMessagesReceivedPerSecond
type OCT2 MaximumNumberOfMessagesForwardedPerSecond
type OCT2 MaximumNumberOfMessagesFilteredPerSecond
type OCT2 MaximumTransitDelayTime_ms
type OCT2 AverageTransitDelayTime_ms
type OCT2 NumberOfMessagesLostDueToBufferOverflow
type OCT2 NumberOfMessagesWithExcessTransitDelayTime