This program was made by and for the Solar Car Team at UVA. This program generates simulated CAN Messages.
- Clone this repo onto your machine
cd
into the project folder- Create a python virtual environment (
py -m venv .venv
) and activate it (.\.venv\Scripts\activate
)- you may need to use
python
orpython3
instead ofpy
- on Mac, run
source ./.venv/bin/activate
to activate the virtual environment
- you may need to use
- Install cantools (
pip install cantools
)
Setting up the Config file
A JSON file must be created. It contains a dictionary (outer dictionary) of dictionaries (inner dictionaries). The keys to the outer dictionary are CAN message names (like ECUMotorCommands
); its value is an inner dictionary. The inner dictionary contains key-value pairs for signals of the CAN message and their value (like "throttle": 25
). Signals left undefined will be assumed to be 0.
The value of a signal will be re-evaluated for every message generated. The value can be dynamically set by using a python expression in a string for a signal's value; the expression can contain these elements:
math
package functions.random
package functions (random was imported asrand
)i
, which is the iteration number of the current message
See config_example.json
for an example.
Running the Program
After completing the steps in Installation, run py main.py path number
- replace
path
with the path of the Config JSON file - replace
number
with the number of messages to be created; can use scientific notation (like1e3
) - the output is stored in
out.txt