Gateway

A small amount of Python code is enough to create a CAN gateway. When the routing requires more application logic, the PyRbs class keeps individual rules direct and manageable.

./rbs/main.py
Copy code
from pyrbs import PyRbs, CanMessagerbs = PyRbs(dashboard=False)@rbs.can_message.on("CAN1.*")def gateway_can1_can2(self: CanMessage):    self.send(channel=2)

Add individual rules only where they are needed

Catch all messages on a channel with one handler, then implement dedicated behavior for the specific CAN messages that require validation, transformation, filtering, or special routing.

This combines a concise default gateway with complete access to the messages that need custom application logic.

./rbs/main.py
Copy code
from pyrbs import PyRbs, CanMessagerbs = PyRbs(dashboard=False)# add more complex logic to the gateway# by implementing rules for specific messages@rbs.can_message.on("CAN1.Control_01")def gateway_control_selector(self: CanMessage):    for selector in [2, 3, 4]:        # adjust the Selector Signal value        self["Selector"].raw = selector        self.send(channel=selector)# pick all messages that have no callback configured@rbs.can_message.on("CAN1.!*")def gateway_can1_to_can234(self: CanMessage):    self.send(channel=2)    self.send(channel=3)    self.send(channel=4)