uds.segmentation.abstract_segmenter

Definition of API for segmentation and desegmentation strategies.

Module Contents

Classes

AbstractSegmenter

Abstract definition of a segmenter class.

exception uds.segmentation.abstract_segmenter.SegmentationError[source]

Bases: ValueError

Inheritance diagram of uds.segmentation.abstract_segmenter.SegmentationError

UDS segmentation or desegmentation process cannot be completed due to input data inconsistency.

Initialize self. See help(type(self)) for accurate signature.

class uds.segmentation.abstract_segmenter.AbstractSegmenter[source]

Bases: abc.ABC

Inheritance diagram of uds.segmentation.abstract_segmenter.AbstractSegmenter

Abstract definition of a segmenter class.

Segmenter classes defines UDS segmentation and desegmentation strategies. They contain helper methods that are essential for successful segmentation and desegmentation execution. Each concrete segmenter class handles a single bus.

property supported_packet_classes(self)

Classes that define packet objects supported by this segmenter.

Return type

Tuple[type]

property initial_packet_types(self)

Types of packets that initiates a diagnostic message transmission for the managed bus.

Return type

uds.messages.PacketTypesTuple

is_supported_packet(self, value)[source]

Check if the argument value is a packet object of a supported type.

Parameters

value (Any) – Value to check.

Returns

True if provided value is an object of a supported packet type, False otherwise.

Return type

bool

is_supported_packets_sequence(self, value)[source]

Check if the argument value is a packet sequence of a supported type.

Parameters

value (Any) – Value to check.

Returns

True if provided value is a packet sequence of a supported type, False otherwise.

Return type

bool

is_initial_packet(self, packet)[source]

Check whether a provided packet initiates a diagnostic message.

Parameters

packet (uds.messages.PacketTyping) – Packet to check.

Raises

TypeError – Provided value is not an object of a supported packet type.

Returns

True if the packet is the only or the first packet of a diagnostic message.

Return type

bool

abstract get_consecutive_packets_number(self, first_packet)[source]

Get number of consecutive packets that must follow this packet to fully store a diagnostic message.

Parameters

first_packet (uds.messages.PacketTyping) – The first packet of a segmented diagnostic message.

Raises

ValueError – Provided value is not an an initial packet.

Returns

Number of following packets that together carry a diagnostic message.

Return type

int

abstract is_following_packets_sequence(self, packets)[source]

Check whether provided packets are a sequence of following packets.

Note: This function will return True under following conditions:
  • a sequence of packets was provided

  • the first packet in the sequence is an initial packet

  • no other packet in the sequence is an initial packet

  • each packet (except the first one) is a consecutive packet for the previous packet in the sequence

Parameters

packets (uds.messages.PacketsSequence) – Packets sequence to check.

Raises

ValueError – Provided value is not a packets sequence of a supported type.

Returns

True if the provided packets are a sequence of following packets, otherwise False.

Return type

bool

is_complete_packets_sequence(self, packets)[source]

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

Parameters

packets (uds.messages.PacketsSequence) – Packets sequence to check.

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

abstract segmentation(self, message)[source]

Perform segmentation of a diagnostic message.

Parameters

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

Raises

TypeError – Provided ‘message’ argument is not UdsMessage type.

Returns

UDS packets that are an outcome of UDS message segmentation.

Return type

uds.messages.PacketsDefinitionTuple

abstract desegmentation(self, packets)[source]

Perform desegmentation of UDS packets.

Parameters

packets (uds.messages.PacketsSequence) – UDS packets to desegment into UDS message.

Raises

SegmentationError – Provided packets are not a complete packet sequence that form a diagnostic message.

Returns

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

Return type

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