uds.segmentation.can_segmenter
Segmentation specific for CAN bus.
Module Contents
Classes
Segmenter class that provides utilities for segmentation and desegmentation on CAN bus. |
- class uds.segmentation.can_segmenter.CanSegmenter(*, addressing_format, physical_ai=None, functional_ai=None, dlc=CanDlcHandler.MIN_BASE_UDS_DLC, use_data_optimization=False, filler_byte=DEFAULT_FILLER_BYTE)[source]
Bases:
uds.segmentation.abstract_segmenter.AbstractSegmenter
Segmenter class that provides utilities for segmentation and desegmentation on CAN bus.
Configure CAN Segmenter.
- Parameters
addressing_format (uds.can.CanAddressingFormatAlias) – CAN Addressing format used.
physical_ai (Optional[AIArgsAlias]) – CAN Addressing Information parameters to use for physically addressed communication. Leave None if the segmenter will not be used for segmenting physically addressed messages.
functional_ai (Optional[AIArgsAlias]) – CAN Addressing Information parameters to use for functionally addressed communication. Leave None if the segmenter will not be used for segmenting functionally addressed messages.
dlc (int) – Base CAN DLC value to use for CAN Packets.
use_data_optimization (bool) – Information whether to use CAN Frame Data Optimization during segmentation.
filler_byte (uds.utilities.RawByte) – Filler byte value to use for CAN Frame Data Padding during segmentation.
- property supported_packet_classes(self)
Classes that define packet objects supported by this segmenter.
- Return type
Tuple[Type[uds.packet.PacketAlias], Ellipsis]
- property addressing_format(self)
CAN Addressing format used.
- Return type
uds.can.CanAddressingFormatAlias
- property physical_ai(self)
CAN Addressing Information parameters used for physically addressed communication.
None if physically addressed communication parameters are not configured.
- Return type
Optional[AIParamsAlias]
- property functional_ai(self)
CAN Addressing Information parameters used for functionally addressed communication.
None if functionally addressed communication parameters are not configured.
- Return type
AIParamsAlias
- property dlc(self)
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(self)
Information whether to use CAN Frame Data Optimization for CAN Packet created during segmentation.
- Return type
bool
- property filler_byte(self)
Filler byte value to use for CAN Frame Data Padding during segmentation.
- Return type
uds.utilities.RawByte
- desegmentation(self, packets)[source]
Perform desegmentation of CAN packets.
- Parameters
packets (uds.packet.PacketsSequence) – 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(self, 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.
AmbiguityError – Segmentation cannot be completed because CAN Segmenter is not properly configured.
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.PacketsDefinitionTuple
- 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.packet.PacketsSequence) – 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
- __physical_segmentation(self, 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.PacketsDefinitionTuple
- __functional_segmentation(self, 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.PacketsDefinitionTuple