Can Isotp Connection Module
- mtf.diag_port.can_isotp_connection.create_can_isotp_connection(channel_name: str, can_variant: str, tx_id: int, rx_id: int, pdu_max_length: int, padding_value: int, flow_timeout: int, source_address: int = 0, target_address: int = 0)
- Create IsoTp connection for CAN and CAN-FD protocols. Args: - channel_name (str): channel name. can_variant (str): protocol (“CAN” or “FD”). tx_id (int): Receiver frame ID. rx_id (int): Transmitter frame ID. pdu_max_length (int): Maximum length of pdu. padding_value (int): Padding value. flow_timeout (int): Flow timeout. source_address (str, optional): Source address. Default to zero (normal addressing). target_address (str, optional): Target address. Default to zero (normal addressing). - returns:
- CanIsotpConnection object: connection object. 
 
- 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 (int) – 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)
- 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. 
 - 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 (int) – 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, including- TimeoutExceptionWhen- False, all exceptions will be logged as- DEBUGand- Nonewill be returned.
 
- Returns:
- Received data 
- Return type:
- bytes or None 
 
 - name: str