remotivelabs.broker
RemotiveLabs Broker API
This module handles communication with the RemotiveBroker.
The RemotiveBroker can run locally or in RemotiveCloud. Connecting to a RemotiveCloud instance requires additional
authentication parameters—see the remotivelabs.broker.auth
module for details.
Installation
pip install remotivelabs-broker
Logging
This library uses Python's standard logging
module. By default, the library does not configure any logging handlers,
allowing applications to fully control their logging setup.
To enable logs from this library in your application or tests, configure logging as follows:
import logging
logging.basicConfig(level=logging.INFO)
logging.getLogger("remotivelabs.broker").setLevel(logging.DEBUG)
For more advanced configurations, refer to the Python logging documentation.
Client for signal-related operations.
Initializes a new BrokerClient instance.
Arguments:
- url: The RemotiveBroker URL to connect to.
- client_id: Optional client ID. If None, a random ID is generated.
- auth: Authentication method to use. Defaults to NoAuth.
Note:
Start the instance using a context manager:
async with BrokerClient(...) as client: ...
Or use the connect/disconnect methods directly:
client = await BrokerClient(...).connect() # ... await client.disconnect()
Read signals from signal cache
Arguments:
- *values: One or more tuples, each containing a namespace and a list of signal names of the signals to read.
Raises:
- ValueError: If the list of values is empty.
Publish a list of signals to the broker.
Arguments:
- *values: One or more tuples, each containing a namespace and a list of signals to publish.
Raises:
- ValueError: If the list of values is empty.
Publish a list of headers to the broker.
Arguments:
- *headers: One or more tuples, each containing a namespace and a list of frame names of which headers to publish.
Raises:
- ValueError: If the list of values is empty.
Subscribe to a list of signals.
Arguments:
- *signals: One or more tuples, each containing namespace and list of signals to subscribe to.
- on_change: Whether to receive updates only on change.
- initial_empty: True will wait until the broker has sent an initial message
Returns:
An asynchronous iterator of lists of Signal objects.
Subscribe to a headers.
Arguments:
- *headers: One or more tuples, each containing namespace and list of frame names of which headers to subscribe to.
- initial_empty: True will wait until the broker has sent an initial message
Returns:
An asynchronous iterator of of Header objects.
Subscribe to a Frames.
Arguments:
- *frames: One or more tuples, each containing namespace and list of frames to subscribe to.
- on_change: Whether to receive updates only on change.
- initial_empty: True will wait until the broker has sent an initial message
- decode_named_values: True will decode named values to str.
Returns:
An asynchronous iterator with Frames.
Set a SecOC property on the broker.
Arguments:
- namespace: Target namespace
- property: The SecOC property to set.
List all frame infos in one or more namespaces.
Arguments:
- namespaces: One or more NamespaceName or NamespaceInfo objects.
Returns:
A list of FrameInfo objects.
Get a frame by name in a specific namespace.
Arguments:
- name: The name of the frame.
- namespace: The namespace name or NamespaceInfo object.
Returns:
The FrameInfo object if found, otherwise None.
List all signal infos in one or more namespaces.
Arguments:
- namespaces: One or more NamespaceName or NamespaceInfo objects.
Returns:
A list of SignalInfo objects.
Get a signal info by name in a specific namespace.
Arguments:
- name: The name of the signal.
- namespace: The namespace name or NamespaceInfo object.
Returns:
The SignalInfo object if found, otherwise None.
A concrete instance of a frame carrying signal values.
Attributes:
- name: Name of the frame.
- namespace: Namespace to which the frame belongs.
- timestamp: in micro seconds, set when first seen.
- signals: Dict with signal names with their current values.
- value: Raw or composite value associated with the frame (e.g., serialized representation).
Metadata about a frame in a namespace.
Attributes:
- name: Name of the frame.
- namespace: Namespace to which the frame belongs.
- signals: Dict of signal names and their corresponding SignalInfo.
- sender: List of entities that send this frame.
- receiver: List of entities that receive this frame.
- cycle_time_millis: Frame cycle time in milliseconds.
Used to subscribe to a frame and optionally its signals.
Attributes:
- name: Name of the frame to subscribe to.
- signals: List of signal names to subscribe to
- None: subscribe to all signals in the frame.
- []: subscribe to the frame without any signals.
A header with its frame name and namespace, used as an arbitration identifier in a communication protocol where only one participant can transmit at a time, for example LIN.
Attributes:
- frame_name: The name of the frame of which header to publish.
- namespace: The namespace the header belongs to.
Configuration for a frame in the Restbus.
Attributes:
- name: The name of the frame to configure.
- cycle_time: Optional cycle time override for the frame. If None, the default from the broker's database is used.
This class defines how a specific signal should behave when emitted by Restbus. A signal can have:
Attributes:
- name: The name of the signal
- loop: Values emitted in order after the initial sequence
- initial: Optional values emitted once before the loop starts
Create a SignalConfig with a constant value.
Arguments:
- name: Name of the signal
- value: Value to set in Restbus
Use CMAC0 for SecOC in the RemotiveBroker.
Set SecOC binary freshness value to be used by freshness manager. Property is limited to SecOC on a given name space.
Set binary 128-bit key to be used for SecOC in the RemotiveBroker.
Multiple keys can be set and are separated by key ID's.
Set a time delta to use in real time clock for SecOC freshness value. Time difference is in floating point seconds and is limited to a name space.
A signal with its name, namespace, and current value.
Attributes:
- name: The name of the signal.
- namespace: The namespace the signal belongs to.
- value: The current value of the signal.
Metadata describing a signal
Attributes:
- name: Name of the signal.
- namespace: Namespace the signal belongs to.
- receiver: List of receivers for the signal.
- sender: List of senders for the signal.
- named_values: Mapping from raw numeric values to symbolic names (e.g., enums).
- value_names: Reverse mapping from symbolic names to raw numeric values.
- min: Minimum allowed value.
- max: Maximum allowed value.
- factor: Multiplication faction used for encoding and decoding value in frame.
A signal intended to be published with a specific value.
Attributes:
- name: The name of the signal to write.
- value: The value to assign to the signal.