uds.can.addressing.addressing_information

Implementation of Addressing Information for CAN bus.

This module contains helper class for managing Addressing Information on CAN bus.

Classes

CanAddressingInformation

CAN Entity (either server or client) Addressing Information.

Module Contents

class uds.can.addressing.addressing_information.CanAddressingInformation[source]

CAN Entity (either server or client) Addressing Information.

Create UDS Addressing Information for a CAN node.

Parameters:
  • addressing_format – CAN Addressing format used by CAN node.

  • rx_physical_params – Addressing Information parameters used for incoming physically addressed communication.

  • tx_physical_params – Addressing Information parameters used for outgoing physically addressed communication.

  • rx_functional_params – Addressing Information parameters used for incoming functionally addressed communication.

  • tx_functional_params – Addressing Information parameters used for outgoing functionally addressed communication.

ADDRESSING_INFORMATION_MAPPING: Dict[uds.can.addressing.addressing_format.CanAddressingFormat, Type[uds.can.addressing.abstract_addressing_information.AbstractCanAddressingInformation]]

Dictionary with CAN Addressing Formats mapped to Addressing Information handler classes.

classmethod get_ai_data_bytes_number(addressing_format)[source]

Get number of data bytes that are used to carry Addressing Information.

Parameters:

addressing_format (uds.can.addressing.addressing_format.CanAddressingFormat) – 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_data_bytes(addressing_format, ai_data_bytes)[source]

Validate Addressing Information stored in CAN data bytes.

Parameters:
Raises:

InconsistencyError – Provided number of Addressing Information data bytes does not match CAN Addressing Format used.

Return type:

None

classmethod validate_addressing_params(addressing_format, addressing_type, can_id=None, target_address=None, source_address=None, address_extension=None)[source]

Validate Addressing Information parameters of a CAN packet.

Parameters:
  • addressing_format (uds.can.addressing.addressing_format.CanAddressingFormat) – CAN addressing format used.

  • addressing_type (uds.addressing.AddressingType) – Addressing type to validate.

  • can_id (Optional[int]) – CAN Identifier value to validate.

  • target_address (Optional[int]) – Target Address value to validate.

  • source_address (Optional[int]) – Source Address value to validate.

  • address_extension (Optional[int]) – Address Extension value to validate.

Returns:

Normalized dictionary with the provided Addressing Information.

Return type:

uds.can.addressing.abstract_addressing_information.CANAddressingParams

classmethod is_compatible_can_id(addressing_format, can_id, addressing_type=None)[source]

Check whether provided CAN ID is consistent the provided CAN Addressing Format.

Parameters:
  • addressing_format (uds.can.addressing.addressing_format.CanAddressingFormat) – Addressing format used.

  • can_id (int) – CAN ID value to check.

  • addressing_type (Optional[uds.addressing.AddressingType]) – Addressing type for which consistency to be performed. Leave None to skip crosscheck between CAN Identifier and Addressing Type.

Returns:

True if CAN ID value is compatible with this CAN Addressing Format, False otherwise.

Return type:

bool

classmethod decode_can_id_ai_params(addressing_format, can_id)[source]

Decode Addressing Information parameters from CAN Identifier.

Parameters:
Returns:

Decoded Addressing Information parameters.

Return type:

uds.can.addressing.abstract_addressing_information.AbstractCanAddressingInformation.CanIdAIParams

classmethod decode_data_bytes_ai_params(addressing_format, ai_data_bytes)[source]

Decode Addressing Information parameters from CAN data bytes.

Parameters:
Returns:

Decoded Addressing Information parameters.

Return type:

uds.can.addressing.abstract_addressing_information.AbstractCanAddressingInformation.DataBytesAIParamsAlias

classmethod decode_frame_ai_params(addressing_format, can_id, raw_frame_data)[source]

Decode Addressing Information parameters from a CAN Frame.

Parameters:
Returns:

Decoded Addressing Information parameters.

Return type:

uds.can.addressing.abstract_addressing_information.AbstractCanAddressingInformation.DecodedAIParamsAlias

classmethod encode_can_id(addressing_format, addressing_type, target_address, source_address, priority=CanIdHandler.DEFAULT_PRIORITY_VALUE)[source]

Generate CAN ID value for Normal Fixed CAN Addressing format.

Parameters:
  • addressing_format (uds.can.addressing.addressing_format.CanAddressingFormat) – Addressing format used.

  • addressing_type (uds.addressing.AddressingType) – Addressing type used.

  • target_address (int) – Target Address value to use.

  • source_address (int) – Source Address value to use.

  • priority (int) – Priority parameter value to use.

Raises:

ValueError – CAN ID cannot be encoded for provided CAN Addressing Format.

Returns:

Value of CAN ID that is compatible with provided CAN Addressing Format and was generated out of the provided values.

Return type:

int

classmethod encode_ai_data_bytes(addressing_format, target_address=None, address_extension=None)[source]

Generate data bytes that carry Addressing Information.

Parameters:
Returns:

Data bytes that carry Addressing Information in a CAN frame Data field.

Return type:

bytearray