Xcp Module

class mtf.measurement.xcp.XCP
values
save_values
init(ecu_name: str, channel_name: str, a2l_file_path: str) bool

Initializes the XCP conection by parsing the a2l file.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel. a2l_file_path (PathStr, Mandatory): Path to the A2L file.

=== Returns ===

bool: True if initialization is successful, False otherwise.

get_values()
deinit(ecu_name: str, channel_name: str) bool

Deinit the XCP connection.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel.

=== Returns ===

bool: True if deinit is successful, False otherwise.

connect(ecu_name: str, channel_name: str, protocol: int = 0, dst_host: str = '', dst_port: int = 0, src_host: str = '', src_port: int = 0, callback: Callable[[str, bool], None] | None = None) bool

Connects to the ECU via the given parameters.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel. protocol (int, Optional): XCP protocol version. Defaults to 0. dst_host (str, Optional): Destination host address. Defaults to “”. dst_port (int, Optional): Destination port number. Defaults to 0. src_host (str, Optional): Source host address. Defaults to “”. src_port (int, Optional): Source port number. Defaults to 0. callback (XcpConnectionStateCallback, Optional): Callback function for connection state changes.

=== Returns ===

bool: True if connection is successful, False otherwise.

disconnect(ecu_name: str, channel_name: str) bool

Disconnects from the ECU .

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel.

=== Returns ===

bool: True if disconnection is successful, False otherwise.

is_connected_by_ecu_name(ecu_name: str) bool

Checks if the ECU is connected via XCP.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU.

=== Returns ===

bool: True if the ECU is connected, False otherwise.

detect_ecus() List[Dict[str, Any]]

Detects available ECUs.

=== Returns ===

list: List of dictionaries containing information about detected ECUs.

get_all_characteristics(ecu_name: str, channel_name: str) list[str]

Retrieves all characteristics.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel.

=== Returns ===

list: List of characteristics.

get_all_measurements(ecu_name: str, channel_name: str) list[dict]

Retrieves all measurements.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel.

=== Returns ===

list: List of dictionaries containing information about measurements.

get_all_ecu_names() list[str]

Retrieves names of all connected ECUs.

=== Returns ===

list: List of ECU names.

get_object_data_type(ecu_name: str, channel_name: str, a2l_object: str) XcpDataType

Get the data type of an object in the XCP instance.

Args:

ecu_name (str): The name of the ECU. channel_name (str): The name of the channel. a2l_object (str): The name of the A2L object.

Returns:

ObjectDataType: The data type of the object.

read_complex_type(ecu_name: str, channel_name: str, a2l_object: str, is_raw_value: bool = False) list[Any]

Reads a complex type from the ECU.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel. a2l_object (str, Mandatory): Name of the A2L object. is_raw_value (bool, Optional): Indicates if the value is raw. Defaults to False.

=== Returns ===

list: List containing the read values.

read(ecu_name: str, channel_name: str, a2l_object: str, is_raw_value: bool = False) Tuple[bool, Any]

Reads a value from the ECU.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel. a2l_object (str, Mandatory): Name of the A2L object. is_raw_value (bool, Optional): Indicates if the value is raw. Defaults to False.

=== Returns ===

tuple: A tuple containing a boolean status and the read value.

write_complex_type(ecu_name: str, channel_name: str, a2l_object: str, value: Any, is_raw_value: bool = True) Tuple[bool, str]

Writes a complex type value to the specified ECU, channel, and A2L object.

=== Arguments Description ===

  • ecu_name * (str): The name of the ECU.

  • channel_name * (str): The name of the channel.

  • a2l_object * (str): The name of the A2L object.

  • value * (Any): The value to write.

  • is_raw_value * (bool): Indicates whether the value is a raw value. Defaults to True.

=== Returns ===

bool: True if the value was successfully written, False otherwise.

write(ecu_name: str, channel_name: str, a2l_object: str, value: Any, is_raw_value: bool = True) bool

Writes a value to the specified A2L object in a given ECU and channel for simple types.

Args:

ecu_name (str): The name of the ECU. channel_name (str): The name of the channel. a2l_object (str): The name of the A2L object. value (Any): The value to be written to the A2L object. is_raw_value (bool, optional): Indicates whether the value is a raw value or not. Defaults to True.

Returns:

bool: True if the write operation was successful, False otherwise.

configure(ecu_name: str, channel_name: str, option: XcpConfigOption, value: int) bool

Configures options for the ECU via XCP.

=== Arguments Description ===

ecu_name (str, Mandatory): Name of the ECU. channel_name (str, Mandatory): Name of the channel. option (XcpConfigOption, Mandatory): Configuration option. value (int, Mandatory): Value to set for the configuration option.

=== Returns ===

bool: True if configuration is successful, False otherwise.

static __new__(cls, *args, **kwargs)

Initialize a new instance of the ControllerBase.

The instance will be automatically added to the list of controllers.

classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

clean_up()

Cleans up the XCP connections and resources.

=== Returns ===

bool: True if cleanup is successful, False otherwise.