Someip Controller Module

SomeipListener Module.

class mtf.network_port.someip_controller.SomeipListener
__init__(channel_name: str = 'ETH-SOMEIP', protocol: ~mtf.proto_common.EthProtocolType | ~mtf.libs.mtf_pybinder.mtf_eth_filter | ~mtf.libs.mtf_pybinder.mtf_someip_filter = <mtf_eth_protocol_type.SOME_IP: 2251799813685248>) None
configure(someip_filter: ~mtf.libs.mtf_pybinder.mtf_someip_filter | None = None, listener_type: ~mtf.libs.mtf_pybinder.SomeIpListenerType = <SomeIpListenerType.GetSeparateFrames: 2>) None
start_listening(keep_cache: bool = False, silent_mode: bool = True) bool

Starts listening on a bus and can be configured to operate in silent mode or to reset cached data before beginning to listen

Args:

keep_cache (bool) silent_mode (bool): Specify whether the listening should be done in silent mode or not

Return:

bool

stop_listening() bool

Stop listening for events on a communication bus Return:

bool

reset() None

Reset the state of the bus listener by clearing its history and emptying the event queue

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

Initializes a new instance of the ControllerBase.

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.

Note:

Do not override this method in subclasses to maintain this functionality.

Args:

*args: Suitable arguments passed to the constructor of the ControllerBase class. **kwargs: keywords passed to the constructor of the ControllerBase class.

Returns:

instance(ControllerBase): The new instance of the class that has been created.

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 the clean_up() method for each instance, since it iterates through the list of controllers to realize any needed cleanup which can fail so an error will be raised. Then, the remaining instances will continue processing.

Returns:

bool: True indicating that all the controllers are successfully cleaned up, otherwise False when an error occurred during the operation of the cleanup.

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.

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)
mtf.network_port.someip_controller.create_someip_filter_from_andi_dict(someip_filter: dict) mtf_someip_filter