CanIsotpConnection
- class mtf.diag_port.can_isotp_connection.CanIsotpConnection
This class overrides BaseConnection methods to support diagnostic over can and can-fd by sending data using MTF.
- __init__(channel: str, protocol: CanProtocol, tx_id: int, rx_id: int, source_address: int = 0, target_address: int = 0, pdu_length: int = 8, padding_value: int = 255, flow_timeout: int = 200)
Constructor for CanIsotpConnection class. Initializes an instance of CanIsotpConnection.
- Args:
channel (str): channel name. protocol (str): protocol (0: CAN or 1: CANFD). tx_id (int): Transmitter frame ID. rx_id (int): Receiver frame ID. source_address (str, optional): Source address. Default to zero (normal addressing). target_address (str, optional): Target address. Default to zero (normal addressing). pdu_length (int): Maximum length of pdu. Default to 8. padding_value (int): Padding value. Default to 0xff. flow_timeout (int): Flow timeout. Default to 200 milliseconds.
- Returns:
None
- logger: Logger
- is_open()
Tells if the connection is open.
- Returns:
bool
- open()
Set up the connection object.
- Returns:
None
- close()
Close the connection object
- Returns:
None
- empty_rxqueue()
Empty all unread data in the reception buffer.
- Returns:
None
- specific_wait_frame(timeout=2)
The implementation of the
wait_framemethod.- Parameters:
timeout (float) – The maximum amount of time to wait before giving up
- Returns:
Received data
- Return type:
bytes or None
- specific_send(payload)
The implementation of the send method.
- Parameters:
payload (bytes) – Data to send
- Returns:
None
- clean_up()
Performs cleanup for the CanIsotpConnection instance.
- Returns:
bool: True if successful, False otherwise.
- static __new__(cls, *args, **kwargs)
Creates a new instance.
- Args:
*args: The variable arguments list. **wargs: The keyword arguments list.
- Returns:
ControllersBase: The newly created instance.
Note:
Note
The instance will be automatically added to the list of controllers to be cleaned up later. It guarantees that all the controller instances are followed up and cleaned up when the associate method ‘controllers_cleanup(cls)’ is called.
Important
Do not override this method in subclasses to maintain this functionality.
- classmethod controllers_cleanup()
Cleans up all controller instances.
It calls clean_up() for each controller in the list. If a cleanup fails, an error is raised, but the method continues processing the remaining controllers.
- Returns:
- bool: True indicating that all controllers were cleaned up successfully.
Otherwise, False is returned when an error occurs during the cleanup process.
- send(data: bytes | Request | Response, timeout: float | None = None) None
Sends data to the underlying transport protocol
- Parameters:
data (bytes, Request, Response) – The data or object to send. If a Request or Response is given, the value returned by get_payload() will be sent.
- Returns:
None
- wait_frame(timeout: float | None = None, exception: bool = False) bytes | None
Waits for the reception of a frame of data from the underlying transport protocol
- Parameters:
timeout (float) – The maximum amount of time to wait before giving up in seconds
exception (bool) – Boolean value indicating if this function may return exceptions. When
True, all exceptions may be raised, includingTimeoutExceptionWhenFalse, all exceptions will be logged asDEBUGandNonewill be returned.
- Returns:
Received data
- Return type:
bytes or None
- name: str