CAN Bus
Configuration
Section titled “Configuration”NeuralPlex utilizes systemd-networkd to configure the baud rate of each CAN bus, as well as other parameters. There are four CAN busses available on NeuralPlex: CAN0, CAN1, CAN2, CAN3. Three of the CAN busses (CAN0-2) are native on the NXP i.MX8QM. Each of these CAN busses are also connected internally to the Vehicle Interface Processor (VIP) CAN busses. The fourth CAN bus is connected to the SOC via the SPI bus.
Setting the baud rate
Section titled “Setting the baud rate”To set the baud rate, modify the desired network file found at: /etc/systemd/network/. For example, to change the baud rate of CAN0 to 500k, use vi to edit the following file:
root@neuralplex:~# vi /etc/systemd/network/can0.network
[Match]Name=CAN0
[CAN]BitRate=500000RestartSec=500msTripleSampling=yesReload CAN bus
Section titled “Reload CAN bus”Once you have made modifications to the can0.network file, you will need to reload the file for the changes to take effect.
root@neuralplex:~# systemctl restart systemd-networkdcan-utils
Section titled “can-utils”NeuralPlex includes can-utils which is useful for interfacing with the CAN bus from userspace.
candump
Section titled “candump”candump lets you sniff CAN packets from one or more CAN interfaces with lots of other useful options to filter, redirect messages etc. Here just a small example:
root@neuralplex:~# candump CAN0 CAN0 123 [4] 01 AA BB 22 CAN0 123 [4] 01 AA BB 23 CAN0 123 [4] 01 AA BB 24cansend
Section titled “cansend”cansend lets you manually send messages on the desired CAN interface. Here is just a small example:
root@neuralplex:~# cansend CAN0 100#DEADBEEF