Skip to content

ResearchYou/Simulator-de-pachete-CAN

Repository files navigation

Simulator-de-pachete-CAN

Prerequisites

  • DirectX End-User Runtime
  • Python 3.7.9
  • CARLA 0.9.11
  • WOKWI VSCode Extension
  • WOKWI Account (for licence generation)

Required libraries

PyQt5=5.15.10
PyQt5-Qt5==5.15.2
PyQt5-sip==12.13.0
pygame==2.6.1
numpy==1.21.6
matplotlib==3.5.3

Packet generation

Once you clone this repo, you need to start the Carla Simulator from the CarlaUE4.exe.

NOTE: FOR BETTER PERFORMANCES, YOU CAN USE THE THE FOLLOWING FLAGS.
-quality-level=Low -resx=800 -resy=600

To connect to the server, we use a custom made client that takes advantage of the CARLA API to interact with the world around it. To run the client, use the follwoing command:

python can_simulator.py

We use the CARLA simulator as a basis for our CAN FD packet generation. By using the J key, we can toggle the recording of packets on/off. This will create a log file with all the data generated and a special data.h file used later by the can-converter chip.

Packet analysis

From inside VSCode, open the Dev Container and compile the wasm for the simulated circuit communication. This can be achieved with the help of the predefined Makefile:

make

After that, we can run the simulator from inside VSCode (F1 - Wokwi: Start Simulator). If you are prompted that you need a licence, activate one from your WOKWI account. Now we need to upload the code we want executed to the simulated Raspberry Pi Pico. From a normal terminal run the follwoing command:

python -m mpremote connect port:rfc2217://localhost:4000 fs cp ..\CAN_ID.json :CAN_ID.json + run .\WOKWI\main2.py

This will copy the CAN_ID.json file to the board and after that run the main2.py script. This script uses a PIO program to read the simulated CAN BUS and interpret the messages in transit. The CAN BUS traffic is generated from the data extracted from CARLA by the can-converter chip, that takes the binary input and translates it to a simulated CAN BUS consisting of CAN_H and CAN_L data lines.

After we stop the simulation, we are prompted to save a vcd file that contains the recorded data from the Logic Analyzer perspective.

This vcd file contains two actual channels, both consisting of a pair of CAN_H and CAN_L lines. Using the vcd_visualiser.py, we can see exatly what packets have been sent during the simulation.

python vcd_viewer.py -path="\PATH\TO\VCD\FILE"

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages