Bus Listener Module

class mtf.network_port.bus_listener.BusListener
__init__(bus_name: str, *args, **kwargs)
get_queue() Queue[BusEvent]

Get the queue

reset()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool
register_callback(callback_fnc: Callable[[BusEvent], None])
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_bus_event_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)
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener, register callback, do work
# register our callback
listener.register_callback(my_bus_event_callback)
callback_(data_frame: BusEvent)
clean_up()
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

classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

class mtf.network_port.bus_listener.CanBusListener
__init__(bus_name: str)
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)
clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

get_queue() Queue[BusEvent]

Get the queue

register_callback(callback_fnc: Callable[[BusEvent], None])
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_bus_event_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()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool
unregister_callback(callback_fnc)
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener, register callback, do work
# register our callback
listener.register_callback(my_bus_event_callback)
class mtf.network_port.bus_listener.LinBusListener
__init__(bus_name: str)
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)
clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

get_queue() Queue[BusEvent]

Get the queue

register_callback(callback_fnc: Callable[[BusEvent], None])
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_bus_event_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()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool
unregister_callback(callback_fnc)
Parameters:

callback_fnc – callback function with parameter of type BusEvent

Setting a callback
# ...
from mtf.mtf_types import BusEvent
# ...

def my_bus_event_callback(msg: BusEvent):
    # do things

# ... creating listener, register callback, do work
# register our callback
listener.register_callback(my_bus_event_callback)
class mtf.network_port.bus_listener.IoListener
__init__(bus_name: str)
property last_value
adapt_queue_elements() Queue[BaseEvent]

ensure the object.timestamp, object.payload

get_queue() Queue[IoEvent]

Get the queue

register_callback(callback_fnc)
Parameters:

callback_fnc – callback function with parameter of type IoEvent

Setting a callback
# ...
from mtf.mtf_types import IoEvent
# ...

def my_callback(msg: IoEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_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)
Parameters:

callback_fnc – callback function with parameter of type BusEvent, which has been registered

:Example def io_listener_callabck(io_event :IoEvent)

callback_(io_event: IoEvent)
static __new__(cls, *args, **kwargs)

Initialize a new instance of the ControllerBase.

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

clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

reset()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool
class mtf.network_port.bus_listener.FlexrayBusListener
__init__(bus_name: str)
get_queue() Queue[FlexrayBusEvent]

Get the queue

register_callback(callback_fnc: Callable[[FlexrayBusEvent], None])
Parameters:

callback_fnc – callback function with parameter of type FlexrayBusEvent

Setting a callback
# ...
from mtf.mtf_types import FlexrayBusEvent
# ...

def my_callback(msg: FlexrayBusEvent):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(my_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)
Parameters:

callback_fnc – callback function with parameter of type FlexrayBusEvent, which has been registered

:Example def flexray_bus_listener_callabck(data_frame :FlexrayBusEvent)

callback_(data_frame: BusEvent)
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

clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

reset()

cleanup the queue

start_listening(silent_mode: bool = False) bool
stop_listening() bool