uds.segmentation.can_segmenter

Segmentation specific for CAN bus.

Module Contents

Classes

CanSegmenter

Segmenter class that provides utilities for segmentation and desegmentation specific for CAN bus.

class uds.segmentation.can_segmenter.CanSegmenter(*, addressing_information, dlc=CanDlcHandler.MIN_BASE_UDS_DLC, use_data_optimization=False, filler_byte=DEFAULT_FILLER_BYTE)[source]

Bases: uds.segmentation.abstract_segmenter.AbstractSegmenter

Inheritance diagram of uds.segmentation.can_segmenter.CanSegmenter

Segmenter class that provides utilities for segmentation and desegmentation specific for CAN bus.

Configure CAN Segmenter.

Parameters:
  • addressing_information (uds.can.AbstractCanAddressingInformation) – Addressing Information configuration of a CAN node.

  • dlc (int) – Base CAN DLC value to use for creating CAN Packets.

  • use_data_optimization (bool) – Information whether to use CAN Frame Data Optimization in created CAN Packets during segmentation.

  • filler_byte (int) – Filler byte value to use for CAN Frame Data Padding in created CAN Packets during segmentation.

property supported_packet_class: Type[uds.packet.AbstractUdsPacket]

Class of UDS Packet supported by CAN segmenter.

Return type:

Type[uds.packet.AbstractUdsPacket]

property supported_packet_record_class: Type[uds.packet.AbstractUdsPacketRecord]

Class of UDS Packet Record supported by CAN segmenter.

Return type:

Type[uds.packet.AbstractUdsPacketRecord]

property addressing_format: uds.can.CanAddressingFormat

CAN Addressing format used.

Return type:

uds.can.CanAddressingFormat

property rx_packets_physical_ai: uds.can.PacketAIParamsAlias

Addressing Information parameters of incoming physically addressed CAN packets.

Return type:

uds.can.PacketAIParamsAlias

property tx_packets_physical_ai: uds.can.PacketAIParamsAlias

Addressing Information parameters of outgoing physically addressed CAN packets.

Return type:

uds.can.PacketAIParamsAlias

property rx_packets_functional_ai: uds.can.PacketAIParamsAlias

Addressing Information parameters of incoming functionally addressed CAN packets.

Return type:

uds.can.PacketAIParamsAlias

property tx_packets_functional_ai: uds.can.PacketAIParamsAlias

Addressing Information parameters of outgoing functionally addressed CAN packets.

Return type:

uds.can.PacketAIParamsAlias

property addressing_information: uds.can.AbstractCanAddressingInformation

Addressing Information configuration of a CAN node.

Return type:

uds.can.AbstractCanAddressingInformation

property dlc: int

Value of base CAN DLC to use for CAN Packets.

Note

All output CAN Packets (created by segmentation()) will have this DLC value set unless CAN Frame Data Optimization is used.

Return type:

int

property use_data_optimization: bool

Information whether to use CAN Frame Data Optimization during CAN Packet creation.

Return type:

bool

property filler_byte: int

Filler byte value to use for CAN Frame Data Padding during segmentation.

Return type:

int

is_input_packet(can_id, data)[source]

Check if provided frame attributes belong to a UDS CAN packet which is an input for this CAN Segmenter.

Parameters:
  • can_id (int) – Identifier of CAN frame to check.

  • data (uds.utilities.RawBytesAlias) – Data field of CAN frame to check.

Returns:

Addressing Type used for transmission of this UDS CAN packet according to the configuration of this CAN Segmenter (if provided attributes belongs to an input UDS CAN packet), otherwise None.

Return type:

Optional[uds.transmission_attributes.AddressingType]

is_desegmented_message(packets)[source]

Check whether provided packets are full sequence of packets that form exactly one diagnostic message.

Parameters:

packets (uds.packet.PacketsContainersSequence) – Packets sequence to check.

Raises:
  • ValueError – Provided value is not CAN packets sequence.

  • NotImplementedError – There is missing implementation for the provided initial packet type. Please create an issue in our Issues Tracking System with detailed description if you face this error.

Returns:

True if the packets form exactly one diagnostic message. False if there are missing, additional or inconsistent (e.g. two packets that initiate a message) packets.

Return type:

bool

desegmentation(packets)[source]

Perform desegmentation of CAN packets.

Parameters:

packets (uds.packet.PacketsContainersSequence) – CAN packets to desegment into UDS message.

Raises:
  • SegmentationError – Provided packets are not a complete packets sequence that form a diagnostic message.

  • NotImplementedError

    There is missing implementation for the provided CAN Packets. Please create an issue in our Issues Tracking System with detailed description if you face this error.

Returns:

A diagnostic message that is an outcome of CAN packets desegmentation.

Return type:

Union[uds.message.UdsMessage, uds.message.UdsMessageRecord]

segmentation(message)[source]

Perform segmentation of a diagnostic message.

Parameters:

message (uds.message.UdsMessage) – UDS message to divide into UDS packets.

Raises:
  • TypeError – Provided value is not instance of UdsMessage class.

  • NotImplementedError

    There is missing implementation for the Addressing Type used by provided message. Please create an issue in our Issues Tracking System with detailed description if you face this error.

Returns:

CAN packets that are an outcome of UDS message segmentation.

Return type:

uds.packet.PacketsTuple

__physical_segmentation(message)

Segment physically addressed diagnostic message.

Parameters:

message (uds.message.UdsMessage) – UDS message to divide into UDS packets.

Raises:

SegmentationError – Provided diagnostic message cannot be segmented.

Returns:

CAN packets that are an outcome of UDS message segmentation.

Return type:

uds.packet.PacketsTuple

__functional_segmentation(message)

Segment functionally addressed diagnostic message.

Parameters:

message (uds.message.UdsMessage) – UDS message to divide into UDS packets.

Raises:

SegmentationError – Provided diagnostic message cannot be segmented.

Returns:

CAN packets that are an outcome of UDS message segmentation.

Return type:

uds.packet.PacketsTuple