Serial Observer Module
This module implements the classes methods needed for observing serial channels and their respective traffic.
- class mtf.network_port.serial_observer.SerialObserver
Implements the functionality to observe serial channels.
- __init__()
Create a new instance.
- Returns:
SerialObserver: The newly created instance.
- start_serial_observer(channel_name: str, get_message_as_string: bool = True)
Start observing the given channel.
- Args:
channel_name (str): The serial channel to observe. get_message_as_string (bool): Whether to get messages as strings or int list (default: True).
- Returns:
bool: True on success, False otherwise.
Examples:
Start serial observerserial_observer_instance = SerialObserver() serial_observer_instance.start_serial_observer("serial_channel_name")
- stop_serial_observer(channel_name: str)
Stop observing the given channel.
- Args:
channel_name (str): The name of the observed channel.
- Returns:
bool: True on success, False otherwise.
Examples:
Stop serial observerserial_observer_instance = SerialObserver() serial_observer_instance.start_serial_observer("serial_channel_name") # Some logic. serial_observer_instance.stop_serial_observer("serial_channel_name")
- stop_all_serial_observers()
Stop all running observers.
- Returns:
bool: True on success, False otherwise.
Examples:
Stop all serial observersserial_observer_instance1 = SerialObserver() serial_observer_instance2 = SerialObserver() serial_observer_instance1.start_serial_observer("serial_channel_name") serial_observer_instance2.start_serial_observer("serial_channel_name") # Some logic. serial_observer_instance.stop_all_serial_observers()
- monitor_happened_serial_events(channel_name: str, message: str | list[int], timeout: int)
Monitor all serial events over the given channel.
- Args:
channel_name (str): The channel to get the events from. message (str or list[int]): The buffer to store the events. timeout (int): Time to wait fo evets (in ms).
- Returns:
bool: True on success, False otherwise.
Examples:
monitor_happened_serial_eventsserial_observer_instance = SerialObserver() serial_observer_instance.monitor_happened_serial_events("serial_channel_name")