Home » Eclipse Projects » Eclipse Titan » Unified Diagnostic Services (UDS) ISO 14229 decoder / encoder(Unified Diagnostic Services RAW encoder / decoder)
Unified Diagnostic Services (UDS) ISO 14229 decoder / encoder [message #1794920] |
Tue, 11 September 2018 02:43  |
Eclipse User |
|
|
|
I have created a subset of the Unified Diagnostic Services (UDS) ISO 14229.
type enumerated SuppressPosRspMsgIndicationBitType {
doNotsuppresssPos (0),
suppresssPos (1)
}
with {variant "FIELDLENGTH(1)"}
type OCT1 DiagnosticSessionType
type record DefaultSessionRequest {
DiagnosticSessionType diagnosticSessionType ('01'O)
} with { variant "" };
type record ProgrammingSessionRequest {
DiagnosticSessionType diagnosticSessionType ('02'O)
} with { variant "" };
type record ExtendedDiagnosticSessionRequest {
DiagnosticSessionType diagnosticSessionType ('03'O)
} with { variant "" };
type record SafetySystemDiagnosticSessionRequest {
DiagnosticSessionType diagnosticSessionType ('04'O)
} with { variant "" };
type union DiagnosticSessionRequestType
{
DefaultSessionRequest defaultSession,
ProgrammingSessionRequest programmingSession,
ExtendedDiagnosticSessionRequest extendedDiagnosticSession,
SafetySystemDiagnosticSessionRequest safetySystemDiagnosticSession
}
with {variant "TAG (
defaultSession, diagnosticSessionType = '01'O;
programmingSession, diagnosticSessionType = '02'O;
extendedDiagnosticSession, diagnosticSessionType = '03'O;
safetySystemDiagnosticSession, diagnosticSessionType = '04'O)";
variant "FIELDLENGTH(7)"
}
type record DiagnosticSessionControlRequestSID
{
SID sid ('10'O),
SuppressPosRspMsgIndicationBitType suppressPosRspMsgIndicationBit,
DiagnosticSessionRequestType diagnosticSessionType
} with { variant "FIELDORDER(msb)" };
type record TesterPresentRequestSID
{
SID sid ('3E'O),
SuppressPosRspMsgIndicationBitType suppressPosRspMsgIndicationBit,
BIT7 zero ('0000000'B)
} with { variant "FIELDORDER(msb)" };
The SuppressPosRspMsgIndicationBitType (1 bit) forms together with the following 7 bit type when encoding / decoding a Byte. That's why I have defined DiagnosticSessionRequestType as FIELDLENGTH(7).
When encoding / decoding DiagnosticSessionRequestType encodes to a 3 byte value instead of the expected 2 byte value '1083'O and decodes even to a differnt than the encoded value (after decoding the suppressPosRspMsgIndicationBit changes from suppresssPos to doNotsuppresssPos):
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Encoding @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { diagnosticSessionControlRequestSID := { sid := '10'O, suppressPosRspMsgIndicationBit := suppresssPos (1), diagnosticSessionType := { extendedDiagnosticSession := { diagnosticSessionType := '03'O } } } }
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Stream after encoding: '100600'O
MTC@Donald: '100600'O
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Encoding @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { diagnosticSessionControlRequestSID := { sid := '10'O, suppressPosRspMsgIndicationBit := suppresssPos (1), diagnosticSessionType := { extendedDiagnosticSession := { diagnosticSessionType := '03'O } } } }
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Stream after encoding: '100600'O
MTC@Donald: decode_TopLevelMessage_UDS_requests(): Stream before decoding: '100600'O
MTC@Donald: decode_TopLevelMessage_UDS_requests(): Decoded @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { diagnosticSessionControlRequestSID := { sid := '10'O, suppressPosRspMsgIndicationBit := doNotsuppresssPos (0), diagnosticSessionType := { extendedDiagnosticSession := { diagnosticSessionType := '03'O } } } }
MTC@Donald: { diagnosticSessionControlRequestSID := { sid := '10'O, suppressPosRspMsgIndicationBit := doNotsuppresssPos (0), diagnosticSessionType := { extendedDiagnosticSession := { diagnosticSessionType := '03'O } } } }
TesterPresentRequestSID with the paramter suppresssPos (1) encodes to '3E80'O, what it should:
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Encoding @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { testerPresentRequestSID := { sid := '3E'O (">"), suppressPosRspMsgIndicationBit := suppresssPos (1), zero := '0000000'B } }
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Stream after encoding: '3E80'O
MTC@Donald: '3E80'O
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Encoding @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { testerPresentRequestSID := { sid := '3E'O (">"), suppressPosRspMsgIndicationBit := suppresssPos (1), zero := '0000000'B } }
MTC@Donald: encode_TopLevelMessage_UDS_requests(): Stream after encoding: '3E80'O
MTC@Donald: decode_TopLevelMessage_UDS_requests(): Stream before decoding: '3E80'O
MTC@Donald: decode_TopLevelMessage_UDS_requests(): Decoded @UnifiedDiagnosticServices.TopLevelMessage_UDS_requests: { testerPresentRequestSID := { sid := '3E'O (">"), suppressPosRspMsgIndicationBit := suppresssPos (1), zero := '0000000'B } }
MTC@Donald: { testerPresentRequestSID := { sid := '3E'O (">"), suppressPosRspMsgIndicationBit := suppresssPos (1), zero := '0000000'B } }
Is it necessary to change the DiagnosticSessionRequestType to:
type BIT7 DiagnosticSessionType
type record DefaultSessionRequest {
DiagnosticSessionType diagnosticSessionType ('0000001'B)
} with { variant "" };
type record ProgrammingSessionRequest {
DiagnosticSessionType diagnosticSessionType ('0000010'B)
} with { variant "" };
type record ExtendedDiagnosticSessionRequest {
DiagnosticSessionType diagnosticSessionType ('0000011'B)
} with { variant "" };
type record SafetySystemDiagnosticSessionRequest {
DiagnosticSessionType diagnosticSessionType ('0000100'B)
} with { variant "" };
type union DiagnosticSessionRequestType
{
DefaultSessionRequest defaultSession,
ProgrammingSessionRequest programmingSession,
ExtendedDiagnosticSessionRequest extendedDiagnosticSession,
SafetySystemDiagnosticSessionRequest safetySystemDiagnosticSession
}
with {variant "TAG (
defaultSession, diagnosticSessionType = '0000001'B;
programmingSession, diagnosticSessionType = '0000010'B;
extendedDiagnosticSession, diagnosticSessionType = '0000011'B;
safetySystemDiagnosticSession, diagnosticSessionType = '0000100'B)";
variant "FIELDLENGTH(7)"
}
|
|
| |
Re: Unified Diagnostic Services (UDS) ISO 14229 decoder / encoder [message #1794986 is a reply to message #1794920] |
Wed, 12 September 2018 04:59  |
Eclipse User |
|
|
|
Hi,
for the second issue: the attribute 'FIELDORDER(msb)' does not extend to lower level records/sets. Because of this the 1 bit for the enumerated type is encoded as the MSB in the octet, and the 7 bits in the ...SessionRequest records are encoded with LSB first (thus overwriting the enum's bit).
This is an undocumented limitation of the attribute FIELDORDER.
To fix this you'd need to add the attribute 'FIELDORDER(msb)' to the ...SessionRequest records.
Like this:
type record DefaultSessionRequest {
RequestDiagnosticSessionType diagnosticSessionType ('0000001'B)
} with { variant "FIELDORDER(msb)" };
type record ProgrammingSessionRequest {
RequestDiagnosticSessionType diagnosticSessionType ('0000010'B)
} with { variant "FIELDORDER(msb)" };
type record ExtendedDiagnosticSessionRequest {
RequestDiagnosticSessionType diagnosticSessionType ('0000011'B)
} with { variant "FIELDORDER(msb)" };
type record SafetySystemDiagnosticSessionRequest {
RequestDiagnosticSessionType diagnosticSessionType ('0000100'B)
} with { variant "FIELDORDER(msb)" };
Best regards,
Botond Baranyi
|
|
|
Goto Forum:
Current Time: Tue Jul 15 16:41:47 EDT 2025
Powered by FUDForum. Page generated in 0.03606 seconds
|