28-01-2023, 10:57 PM
Voici ma documentation. Ça devrait aider :idea:
Installer les outils CAN :
sudo apt install can-utils
voir ceci au cas où : https://github.com/linux-can/can-utils
Configurer l’interface à 500,000 bits/second:
On peut lancer le script CAN-start.sh
sudo ip link set can0 type can bitrate 500000 restart-ms 100
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up can0
Vérifier si les drivers CAN se sont bien chargés
lsmod | grep "can"
can_raw 20480 1
can 24576 1 can_raw
vcan 16384 0
can_dev 40960 1 gs_usb
Vérifier si l’interface est UP :
ip addr ls dev can0
9: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP group default qlen 10
link/can
To send data to the CAN bus, use the cansend utility:
~cansend can0 123#1122334455667788
The above command will send a CAN message on can0 with the identifier 0x123 and the data bytes [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 ]. Values are always treated as hexadecimal.
Pour afficher les valeurs temps réels du bus CAN, on utilise la commande candump:
candump can0
Ou plus précisément pour le Pi
candump -ta -a -x can0
Basic tools to display, record, generate and replay CAN traffic
Installer les outils CAN :
sudo apt install can-utils
voir ceci au cas où : https://github.com/linux-can/can-utils
Configurer l’interface à 500,000 bits/second:
On peut lancer le script CAN-start.sh
sudo ip link set can0 type can bitrate 500000 restart-ms 100
sudo modprobe vcan
Code :
sudo
modprobe can_raw
sudo ip link add dev vcan0 type vcan
sudo ip link set up can0
Vérifier si les drivers CAN se sont bien chargés
lsmod | grep "can"
can_raw 20480 1
can 24576 1 can_raw
vcan 16384 0
can_dev 40960 1 gs_usb
Vérifier si l’interface est UP :
ip addr ls dev can0
9: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UP group default qlen 10
link/can
To send data to the CAN bus, use the cansend utility:
~cansend can0 123#1122334455667788
The above command will send a CAN message on can0 with the identifier 0x123 and the data bytes [ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88 ]. Values are always treated as hexadecimal.
Pour afficher les valeurs temps réels du bus CAN, on utilise la commande candump:
candump can0
Ou plus précisément pour le Pi
candump -ta -a -x can0
Basic tools to display, record, generate and replay CAN traffic
- candump : display, filter and log CAN data to files
- canplayer : replay CAN logfiles
- cansend : send a single frame
- cangen : generate (random) CAN traffic
- cansequence : send and check sequence of CAN frames with incrementing payload
- cansniffer : display CAN data content differences
Jean-Luc