Diagnostic Messages

Implementation related to diagnostic messages and packets is located in uds.messages sub-package.

UDS Message Implementation

Diagnostic messages implementation is divided into two parts:
  • UDS Message - storage for a temporary diagnostic message definition on the user side

  • UDS Message Record - storage for historic information of a diagnostic message that was either received or transmitted

UDS Message

UdsMessage class is meant to provide containers for diagnostic messages information. Once a diagnostic message object is created, it stores diagnostic message data that were provided by a user. One can use these objects to execute complex operations (provided in other subpackages) such as diagnostic messages transmission or segmentation.

All UdsMessage attributes are validated on each value change, therefore a user will face an exception if one tries to set an invalid (incompatible with the annotation) value to of these attributes.

Attributes implemented in UdsMessage class:

Example code:

from uds.messages import UdsMessage, AddressingType

# example how to create an object
uds_message = UdsMessage(payload=[0x10, 0x03],
                         addressing=AddressingType.PHYSICAL)

# raw message attribute
print(uds_message.payload)
uds_message.payload = (0x62, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF)
print(uds_message.payload)
uds_message.payload = [0x3E, 0x80]
print(uds_message.payload)

# addressing attribute
print(uds_message.addressing)
uds_message.addressing = AddressingType.FUNCTIONAL
print(uds_message.addressing)
uds_message.addressing = AddressingType.PHYSICAL.value
print(uds_message.addressing)

UDS Message Record

UdsMessageRecord class is meant to provide container for historic information of diagnostic messages that were either transmitted or received. A user shall not create objects of this class in normal cases, but one would probably use them quite often as they are returned by other layers of uds package.

All UdsMessageRecord attributes are read only (they are set only once upon an object creation) as they store historic data and history cannot be changed (can’t it, right?). A user will face an exception if one tries to modify any attribute.

Attributes implemented in UdsMessageRecord class:

UDS Packet Implementation

UDS packets implementation is divided into three parts:

UDS Packet Type

UDS packet types are supposed to be understood as values of Network Protocol Control Information (N_PCI). Supported values of UDS packet types are defined in specially designed for this purpose enum classes.

Enum classes that implements UDS packet types:

AbstractUdsPacketType

AbstractUdsPacketType class is an empty enum that is a parent class for all concrete UDS packet types enum classes. It provides common API and values restriction (UDS packet type values must be 4-bit integer) for all children classes.

A user shall not use AbstractUdsPacketType directly, but one is able (and encouraged) to use AbstractUdsPacketType implementation with any of its children classes.

Methods implemented in AbstractUdsPacketType class:

UDS Packet

UDS packets differs for each communication bus, therefore multiple classes implementing them are defined. Each UDS packet class provides containers for Network Protocol Data Unit (N_PDU) information that are specific for a communication bus for which this class is relevant. Objects of UDS packet classes might be used to execute complex operations (provided in other subpackages) such as packets transmission or desegmentation.

Implemented UDS packet classes:

AbstractUdsPacket

AbstractUdsPacket class contains common implementation and provides common API for all UDS Packet classes as they are inheriting after AbstractUdsPacket class.

A user shall not use AbstractUdsPacket directly, but one is able (and encouraged) to use AbstractUdsPacket implementation with any of its children classes.

Properties implemented in AbstractUdsPacket class:

UDS Packet Record

UDS packet record is a container that stores historic information of UDS packet (N_PDU) that was either received or transmitted. UDS packets differs for each communication bus, therefore multiple classes implementing UDS packet records are defined.

A user shall not create objects of UDS packet record classes in normal cases, but one would probably use them quite often as they are returned by other layers of uds package.

Implemented UDS packet record classes:

AbstractUdsPacketRecord

AbstractUdsPacketRecord class contains common implementation and provides common API for all UDS Packet classes as they are inheriting after AbstractUdsPacketRecord class.

A user shall not use AbstractUdsPacketRecord directly, but one is able (and encouraged) to use AbstractUdsPacketRecord implementation with any of its children classes.

Properties implemented in AbstractUdsPacketRecord class:

UDS Messages Data

Implementation of data parameters that are defined by UDS specification.

UDS data parameters:

Service Identifiers

POSSIBLE_REQUEST_SIDS

POSSIBLE_REQUEST_SIDS is a set with all possible values of Service Identifier data parameter in a request message.

RequestSID

Enum RequestSID contains definitions of request Service Identifiers values.

Methods implemented in RequestSID class:

POSSIBLE_RESPONSE_SIDS

POSSIBLE_RESPONSE_SIDS is a set with all possible values of Service Identifier data parameter in a response message.

ResponseSID

Enum ResponseSID contains definitions of response Service Identifiers values.

Methods implemented in ResponseSID class:

Negative Response Codes

Enum NRC contains definitions of all common (defined by ISO 14229) Negative Response Codes values.

Methods implemented in NRC class:

Transmission Attributes

Attributes that describes UDS communication:

Addressing

Enum AddressingType contains definitions of addressing values that determines UDS communication model:
Methods implemented in AddressingType class:

Transmission Direction

Enum TransmissionDirection contains definitions of communication directions:
Methods implemented in TransmissionDirection class: