uds.can.addressing_information
Implementation of CAN Addressing Information.
This module contains helper class for managing Addressing Information on CAN bus.
Module Contents
Classes
Helper class that provides utilities for CAN Addressing Information. |
Attributes
Alias of Addressing Information that is carried in data bytes. |
|
Alias of Addressing Information. |
- uds.can.addressing_information.AIDataBytesAlias
Alias of Addressing Information that is carried in data bytes.
- uds.can.addressing_information.AIAlias
Alias of Addressing Information.
- class uds.can.addressing_information.CanAddressingInformationHandler[source]
Helper class that provides utilities for CAN Addressing Information.
Note
CAN Addressing Information and its providing depends on CAN addressing formats used.
Warning
This class contains only implementation that is consistent with ISO 15765 and it does not take into account system specific requirements.
- ADDRESSING_TYPE_NAME
Name of Addressing Type parameter in Addressing Information.
- TARGET_ADDRESS_NAME
Name of Target Address parameter in Addressing Information.
- SOURCE_ADDRESS_NAME
Name of Source Address parameter in Addressing Information.
- ADDRESS_EXTENSION_NAME = address_extension
Name of Address Extension parameter in Addressing Information.
- classmethod decode_ai(cls, addressing_format, can_id, ai_data_bytes)[source]
Decode Addressing Information from CAN ID and data bytes.
Warning
This methods might not extract full Addressing Information from the provided data as some of these information are system specific.
For example, Addressing Type will not be decoded when either Normal 11bit, Extended or Mixed 11bit addressing format is used as the Addressing Type (in such case) depends on system specific behaviour.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN Addressing Format used.
can_id (int) – Value of CAN Identifier.
ai_data_bytes (uds.utilities.RawBytes) – Data bytes containing Addressing Information. This shall be either 0 or 1 byte located at the beginning of a CAN frame data field. Number and content of these bytes depends on CAN Addressing Format used.
- Returns
Dictionary with Addressing Information decoded out of the provided CAN ID and Addressing Information data bytes.
- Return type
AIAlias
- classmethod decode_ai_data_bytes(cls, addressing_format, ai_data_bytes)[source]
Decode Addressing Information from CAN data bytes.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN Addressing Format used.
ai_data_bytes (uds.utilities.RawBytes) – Data bytes containing Addressing Information. This shall be either 0 or 1 byte located at the beginning of a CAN frame data field. Number and content of these bytes depends on CAN Addressing Format used.
- Raises
NotImplementedError – There is missing implementation for the provided Addressing Format. Please create an issue in our Issues Tracking System with detailed description if you face this error.
- Returns
Dictionary with Target Address and Address Extension values decoded out of Addressing Information data bytes.
- Return type
AIDataBytesAlias
- classmethod encode_ai_data_bytes(cls, addressing_format, target_address=None, address_extension=None)[source]
Generate a list of data bytes that carry Addressing Information.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN Addressing Format used.
target_address (Optional[uds.utilities.RawByte]) – Target Address value used.
address_extension (Optional[uds.utilities.RawByte]) – Source Address value used.
- Raises
NotImplementedError –
There is missing implementation for the provided Addressing Format. Please create an issue in our Issues Tracking System with detailed description if you face this error.
- Returns
List of data bytes that carry Addressing Information in CAN frame Data field.
- Return type
uds.utilities.RawBytesList
- classmethod get_ai_data_bytes_number(cls, addressing_format)[source]
Get number of data bytes that are used to carry Addressing Information.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN Addressing Format used.
- Returns
Number of data bytes in a CAN Packet that are used to carry Addressing Information for provided CAN Addressing Format.
- Return type
int
- classmethod validate_ai(cls, addressing_format, addressing_type, can_id=None, target_address=None, source_address=None, address_extension=None)[source]
Validate Addressing Information.
This methods performs comprehensive check of Network Addressing Information (N_AI) to make sure that every required argument is provided and their values are consistent with CAN Addressing Format.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN addressing format value to validate.
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type value to validate.
can_id (Optional[int]) – CAN Identifier value to validate.
target_address (Optional[uds.utilities.RawByte]) – Target Address value to validate.
source_address (Optional[uds.utilities.RawByte]) – Source Address value to validate.
address_extension (Optional[uds.utilities.RawByte]) – Address Extension value to validate.
- Raises
UnusedArgumentError – Value for at least one unused argument (not relevant for this can addressing format) was provided.
NotImplementedError –
There is missing implementation for the provided Addressing Format. Please create an issue in our Issues Tracking System with detailed description if you face this error.
- Return type
None
- static validate_ai_normal_11bit(addressing_type, can_id)[source]
Validate Addressing Information parameters for Normal 11-bit CAN Addressing format.
- Parameters
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type to validate.
can_id (int) – CAN Identifier value to validate.
- Raises
InconsistentArgumentsError – Provided values are not consistent with each other (cannot be used together) or with the Normal 11-bit Addressing format.
- Return type
None
- static validate_ai_normal_fixed(addressing_type, can_id=None, target_address=None, source_address=None)[source]
Validate Addressing Information parameters for Normal Fixed CAN Addressing format.
- Parameters
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type to validate.
can_id (Optional[int]) – CAN Identifier value to validate.
target_address (Optional[uds.utilities.RawByte]) – Target Address value to validate.
source_address (Optional[uds.utilities.RawByte]) – Source Address value to validate.
- Raises
InconsistentArgumentsError – Provided values are not consistent with each other (cannot be used together) or with the Normal Fixed Addressing format.
- Return type
None
- static validate_ai_extended(addressing_type, can_id, target_address)[source]
Validate Addressing Information parameters for Extended CAN Addressing format.
- Parameters
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type to validate.
can_id (int) – CAN Identifier value to validate.
target_address (uds.utilities.RawByte) – Target Address value to validate.
- Raises
InconsistentArgumentsError – Provided values are not consistent with each other (cannot be used together) or with the Extended Addressing format.
- Return type
None
- static validate_ai_mixed_11bit(addressing_type, can_id, address_extension)[source]
Validate Addressing Information parameters for Mixed 11-bit CAN Addressing format.
- Parameters
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type to validate.
can_id (int) – CAN Identifier value to validate.
address_extension (uds.utilities.RawByte) – Address Extension value to validate.
- Raises
InconsistentArgumentsError – Provided values are not consistent with each other (cannot be used together) or with the Mixed 11-bit Addressing format.
- Return type
None
- static validate_ai_mixed_29bit(addressing_type, address_extension, can_id=None, target_address=None, source_address=None)[source]
Validate Addressing Information parameters for Mixed 29-bit CAN Addressing format.
- Parameters
addressing_type (uds.transmission_attributes.AddressingTypeAlias) – Addressing type to validate.
can_id (Optional[int]) – CAN Identifier value to validate.
target_address (Optional[uds.utilities.RawByte]) – Target Address value to validate.
source_address (Optional[uds.utilities.RawByte]) – Source Address value to validate.
address_extension (uds.utilities.RawByte) – Address Extension value to validate.
- Raises
InconsistentArgumentsError – Provided values are not consistent with each other (cannot be used together) or with the Mixed 29-bit Addressing format.
- Return type
None
- classmethod validate_ai_data_bytes(cls, addressing_format, ai_data_bytes)[source]
Validate Addressing Information stored in CAN data bytes.
- Parameters
addressing_format (uds.can.addressing_format.CanAddressingFormatAlias) – CAN Addressing Format used.
ai_data_bytes (uds.utilities.RawBytes) – Data bytes to validate.
- Raises
InconsistentArgumentsError – Provided number of Addressing Information data bytes does not match Addressing Format used.
- Return type
None