Restbus Simulation
the PyRbs python Class is where all the magic happens with it you control Timers, CAN Messages and Signals allong with Statemachines and System Variables react on changes or updates in state or values
Create your Event Driven Restbus Simulation
Using the @rbs decorator gives you access to all kinds of events that occur behind the scenes. These include RX and TX of CAN messages, updates or changes to CAN signal values and elapsed timers. You can also monitor changes in state machines or service events on one of the many diagnosis protocols, such as UDS or CANopen.
Use the widely know DBC or ARXML format to describe your Communication allong with some TOML configurations and a python requirements.txt file
Configure a Simulation
Repo Structure
can.toml
requirements.txt
can1.dbc
Multiply your Simulation
Incase you have multiple DUT´s on a Testbench you can create a Profile and define just the delta to your base configuration. This allows to scale a project fast into a multi DUT setup on just one pyCANdo device.
Repo Structure
DUT1.toml
DUT2.toml
Use the python statemachine package do describe your applications logic.
Statemachines
By using the event driven decorators like @rbs.state.on_enter you can implement the desired changes in timers, message sending or singnal values. Convert your defined logic into a mermaind sting to get a Diagram.
Questions & Answers
But Python is a slow Programming Language
Yes this is way all the heavy lifting that is not your bussiness logic is done by RUST in the backround.
Is Real Time possible with pyCANdo
This depends on your definition of ‚real time‘ and your requirements. To achieve a deterministic and timely system, we use all possible tricks from the Linux Preempt Patch to isolating cores. This allows for very accurate timings and predictable responses.
So can i actually use any Python Package I like
Yes, but there are some limits to how far you can wander off the beaten track. As the GIL still applies to Python, you’re not encouraged to start your own asynchronous threads. It is also not sensible to perform blocking tasks, such as a GET request, inside an @rbs decorator. Using numpy, polars, pandas or scipy is highly encouraged.
How many Simulations can i run in parallel
This depends on the number of cores in your hardware. As a rule of thumb, three cores are currently used for utilities and RT magic. You can run as many simulations as there are cores left, with each simulation running on its own core.