SomeipSDWatcher
- class mtf.network_port.someip_sd_watcher.SomeipSDWatcher
SomeipSDWatcher class
- __init__(channel_name='', protocol: ~mtf.proto_common.EthProtocolType | ~mtf.libs.mtf_pybinder.mtf_eth_filter | ~mtf.libs.mtf_pybinder.mtf_someipsd_filter = <mtf_eth_protocol_type.SOME_IP_SD: 4503599627370496>)
Initialization of all SomeipSDWatcher class attributes
- check_Repetition_phase_someip_sd(queue, ecu_name)
Checks the repetition phase timing constraints for SOME/IP-SD services (both provided and consumed) for a given ECU based on captured message queue.
- Args:
queue (list): List of captured SOME/IP-SD messages. ecu_name (str): The name of the ECU to be checked.
- Returns:
- bool: True if all services with sufficient messages satisfy their repetition
constraints, False if any service fails the check.
- checklist(someip_filter: {} = None)
Ensures the input someip_filter is returned as a list.
- Args:
someip_filter (FilterType): The filter to be processed (could be a list or a single filter)
- Returns:
list: A list containing the filter.
- check_filter_keys()
Checks the filter keys for a given message.
Returns: bool: True if both the SOME/IP layer filter and the SOME/IP-SD entry filter are successful, otherwise False.
- start_listening(keep_cache: bool = False, silent_mode: bool = True, sd_entry_filter: {} = None, sd_message_filter: {} = None, channel: str = None, callback_fnc=None)
start watching to the SOMEIP/SD bus.
- Parameters:
sd_entry_filter (dict <keys:values>, optional) – list of attribute to filter on
sd_message_filter (dict<layer:filter> : filter<key:value>) – list filter message
Example Filterswatcher.start_listening( sd_entry_filter={'service_id': 0x1111, "type": 0x1, "instance_id": 0x1, "ttl": 0x3}, sd_message_filter={'ipv4_header': {'ip_address_source': '1192.168.0.1'}} )
- Returns:
True or false, executed successfully or not
- stop_listening(flush_event_history: bool = True)
Stop watching to the SOMEIP/SD bus. :return: :rtype:
- reset() None
Resets the state of the bus listener by clearing its history and emptying the event queue.
- get_messages()
Retrieves the current message queue after filling it.
- Returns:
list: The current list of messages in the message queue.
- get_sd_entries()
Retrieves the current Service Discovery entries after filling the queue.
- Returns:
list: The current list of Service Discovery entries in the SD entry queue.
- wait_for_sd_entry(entry_filter: list = None, timeout: int = 30, entry_counter: int = 0, remove_msg_filter: bool = True)
Waits for the Service Discovery (SD) entries to reach a specified count within a timeout period.
- Args:
entry_filter (list, optional): A list of filters to apply to the SD entries. Defaults to None. timeout (int, optional): The maximum time to wait for the SD entries, in seconds. Defaults to 30. entry_counter (int, optional): The minimum number of entries required in the queue before returning. Defaults to 0. remove_msg_filter (bool, optional): Whether to clear any existing message filters during the wait. Defaults to True.
- Returns:
list: The list of Service Discovery entries in the queue after the wait period.
- wait_for_someip_sd_message(message_filter: list = None, timeout: int = 30, message_counter: int = 0, remove_entry_filter: bool = True)
Waits for the Service Discovery (SD) messages to reach a specified count within a timeout period.
- Args:
message_filter (list, optional): A list of filters to apply to the SD messages. Defaults to None. timeout (int, optional): The maximum time to wait for the SD messages, in seconds. Defaults to 30. message_counter (int, optional): The minimum number of messages required in the queue before returning. Defaults to 0. remove_entry_filter (bool, optional): Whether to clear any existing entry filters during the wait. Defaults to True.
- Returns:
list: The list of Service Discovery messages in the queue after the wait period.
- 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.
- adapt_queue_elements() Queue[BaseEvent]
ensure the object.timestamp, object.payload
- clean_up()
This method cleans up resources used by the listener by stopping any ongoing operations and resetting the listener’s internal state to ensure it is in a clean and ready state for future use.
- Returns:
bool: Returns True if the cleanup is successfully done. False if an exception occurs.
- 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.
- get_queue() list[dict[str, Any]]
Reset the internal state of an instance of the EthBusListener class
- get_timestamp_queue() list[int]
Retrieve the private attribute _timestamp_queue Return:
list[int]
- register_callback(callback_fnc: Callable[[IEthernetProtocol], None])
- Parameters:
callback_fnc – callback function with parameter of type
MessageEthernet
Setting a callback# ... from andisdk import MessageEthernet # ... def eth_listener_callback(msg: MessageEthernet): # do things # ... creating listener # register our callback listener.register_callback(eth_listener_callback)
Warning
The callback function should be lightweight without logs. Otherwise, it will reduce the performance dramatically. The object that is passed to callback functions is mutable. So the user must be careful. In case of silent mode, the callback functions will be invoked only when getting the queue.
- set_queue_size(max_size: int)
This call of set queue size will clear the queue and resize it better to call it at the beginning : before start listening if max_size <= 0 the queue size is infinite
- unregister_callback(callback_fnc: Callable[[IEthernetProtocol], None])
- Parameters:
callback_fnc – callback function with parameter of type
MessageEthernet
Remove a callback# ... from andisdk import MessageEthernet # ... def eth_listener_callback(msg: MessageEthernet): # do things # ... creating listener # ... do work # unregister our callback listener.unregister_callback(eth_listener_callback)