Can Tp Module
- class mtf.diag_port.can_tp.CanTp
- __init__()
Constructor for CanTp class. Initializes an instance of CanTp.
- Args:
None
- Returns:
None
- send(payload: list)
Sends a payload using the configured can tp connection. support sending can/canfd message
- Args:
payload (list): The payload to be sent.
- Returns:
- None or bool: Returns None if the controller is not configured,
else returns the result of the controller’s transmit method.
- close()
Closes the CanTp instance and cleans up the controller.
- Args:
None
- Returns:
bool: True if successfully closed, False otherwise.
- recv()
Receives a frame from the configured controller.
- Args:
None
- Returns:
None or received_frame: None if no frame received, else the received frame.
- bind(interface, address: Address, *args, **kwargs)
Binds the CanTp instance to a specific interface and frame IDs. This function is used to configure the CANTP connection by specifying the connection parameters. note: doesn’t support canfd support normal addressing incase : source_address = 0 && target_address=0 Args:
interface (str): Name of the interface.(channel name) address (isotp.Address): isotp.Address instance that will take the Receiver frame ID (rxid),
Transmitter frame ID (txid), source address and target address.
- Returns:
bool: True if successful, False otherwise.
- Configure(interface, rxid, txid, protocol: CanProtocol = CanProtocol.CAN, pdu_length=8, padding_value=255, flow_timeout=200, *args, **kwargs)
Configures the CanTp communication with specified parameters. This function is used to configure the CANTP connection by specifying the connection parameters. note: support canfd
- Args:
interface (str): Name of the interface. (channel name) rxid (int): Receiver frame ID. txid (int): Transmitter frame ID. protocol (CanProtocol): CAN protocol type. pdu_length (int): PDU length. padding_value (int): Padding value. flow_timeout (int): Flow timeout.
- Returns:
bool: True if successful, False otherwise.
- configure_flow_control(block_size: int, separation_time: int)
Configures the flow control parameters for CanTp.
- Args:
block_size (int): Block size for flow control. separation_time (int): Separation time for flow control.
- Returns:
bool: True if successful, False otherwise.
- update_transmission_timeout(tx_timeout: int)
Updates the transmission timeout for CanTp, the default value is 100ms.
Note: When tx_timeout is set to 0, it will disable the transmission check.
- Args:
tx_timeout (int): Transmission timeout in milliseconds.
- Returns:
bool: True if successful, False otherwise.
- get_can_tp_queue()
Gets the CanTp queue.
- Returns:
list: The CanTp queue.
- reset_can_tp_queue()
Resets the CanTp queue.
- Returns:
None
- clean_up()
Performs cleanup for the CanTp instance.
- Returns:
bool: True if 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.