How to use CanBus with Python on Jetson™ Xavier™ NX Module?

How to use CanBus with Python on Jetson™ Xavier™ NX Module?

Jetson Xavier NX

24 February 2021
WHAT YOU WILL LEARN?

1- Installing CanBus python packages

2- Using CanBus analyser on host machine

3- Communicating via CanBus 

ENVIRONMENT

Hardware: DSBOX-NX2 & DSBOARD-NX2

OS: Applied to all JetPack Versions



In this post, we will use CanBus standard with Python on NVIDIA Jetson NX Module. For doing that, we will use a host machine which has Windows 10 operating system, "IXXAT Usb-to-Can converter" and NVIDIA Jetson NX Module. We need to install Can Analyser interface for checking data stream.


Firstly, download two zip files at the top of the post, go the two zip file’s location and extract them with unzip command on terminal. Then We have to run the script which enables us to use Can standard like below.


sudo chmod +x enable_can_nx.sh
./enable_can_nx.sh


"python3-pip", "python3-can" should be install by using "sudo apt-get install" command. "can" and "python-can" should be installed with by using "pip3" command.

sudo apt-get install python3-pip
pip3 install can
sudo apt-get install python3-can
pip3 install python-can
pip3 install python-can --upgrade


On host side, we have to make sure that the bitrate and protocol are set as "Both" and "500kbit/s" respectively. For doing that, we should click the "setting button".


Then we can set the bitrate and protocol properties from this window. When we are done with the arrangements, we should click the "OK" button.


We use the script to transmit and receive data via CanBus. You can find the script at the end of the post.


sudo python3 testcanbus.py


When we run this script on NVIDIA Jetson NX module, a message will be sent to host machine from the Jetson module.

The sent message can be seen on Can Analyser interface like below.



The written data can be seen on Jetson module.


Thank you for reading our blog post. 



English