Someip Sd Watcher Module

class mtf.network_port.someip_sd_watcher.EntryType

Enumeration for various SOME/IP message types related to service discovery and event handling.

FindService
OfferService
RequestService
RequestServiceAck
FindEventGroup
PublishEventGroup
SubscribeEventGroup
SubscribeEventGroupAck
Unknown
__new__(value)
conjugate()

Returns self, the complex conjugate of any int.

bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
to_bytes(length, byteorder, *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

from_bytes(byteorder, *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value.

signed

Indicates whether two’s complement is used to represent the integer.

as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
real

the real part of a complex number

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

denominator

the denominator of a rational number in lowest terms

class mtf.network_port.someip_sd_watcher.SomeipSDWatcher

SomeipSDWatcher class

__init__(channel_name='', protocol=<mtf_eth_protocol_type.SOME_IP_SD: 4503599627370496>)

Initialization of all SomeipSDWatcher class attributes

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_watching(sd_entry_filter: {} = None, sd_message_filter: {} = None, channel: str = None, silent_mode: bool = False)

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:

watcher.start_watching(

sd_entry_filter={‘ttl’: 3, ‘instance_id’:0x0001}, sd_message_filter={‘ipv4_header’: {‘ip_address_source’: ‘192.168.0.1’}}

)

Returns:

True or false, executed successfully or not

start_listening(sd_entry_filter: {} = None, sd_message_filter: {} = None, channel: str = None, silent_mode: bool = False)

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 Filters
watcher.start_watching(
    sd_entry_filter={'ttl': 3, 'instance_id':0x0001},
    sd_message_filter={'ipv4_header': {'ip_address_source': '1192.168.0.1'}}
)
Returns:

True or false, executed successfully or not

stop_watching()

Stop watching to the SOMEIP/SD bus. :return: :rtype:

stop_listening()

Stop watching to the SOMEIP/SD bus. :return: :rtype:

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 = 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 = 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)

Initialize a new instance of the ControllerBase.

The instance will be automatically added to the list of controllers.

adapt_queue_elements() Queue[BaseEvent]

ensure the object.timestamp, object.payload

callback_(data_frame: BusEvent)

used as a callback function when an event or frame is received on the communication bus Args:

data_frame (BusEvent): The data frame

clean_up()

Performs the cleanup of internal resources, including resetting queues and filters.

Returns:

bool: True if the cleanup was successful, False if an error occurred during cleanup.

classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

get_message_queue() list[dict[str, Any]]

Get messages queue :return: :rtype:

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.

reset() None

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

start(channel=None, keep_cache=False, silent_mode: bool = False)

Start a listener on a specific channel Args:

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

Return:

bool

stop()

Stop a listener on a specific channel

Return:

bool

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)