CAN communication - AD-EYE/AD-EYE_Core GitHub Wiki
Set CAN bus configuration on PX2
Cross-compilation setup: https://docs.nvidia.com/drive/driveworks-3.5/dwx_samples_building_V5L.html
DPX2 CAN ports mapping table
On NVIDIA DRIVE PX2 , CAN ports are mapped in this way:
- can-5 -> can0 on Tegra A (CAN E)
- can-6 -> can1 on Tegra B (CAN F)
- can-1 -> channel A on Aurix
- can-2 -> channel B on Aurix
- can-3 -> channel C on Aurix
- can-4 -> channel D on Aurix
Usage of CAN ports of drive px2
Setup guide
You can do this by following this link : https://forums.developer.nvidia.com/t/drivepx2-easycan-setup-guide/60271
To find these files :
- LINUX_LXTHREADSX86_DrivePxApp.elf
- EasyCanConfigFile.conf
- DrivePxApp.conf
You can find in DPX2-P2379-EB-V4.02.02_release.zip at this path : ~/nvidia/nvidia_sdk/DRIVE_OS_5.0.10.3_SDK_with_DriveWorks_Linux_OS_PX2_AUTOCHAUFFEUR/DriveSDK/drive-t186ref-foundation/utils/scripts
on Host PC.
Issues
If you're having trouble synchronizing the time between Aurix and Tegra, you can solve the problem by following this link : https://forums.developer.nvidia.com/t/how-to-set-aurix-time-on-px2/71172
Sending CAN messages
Sending random messages to CAN-E or CAN-F :
(On Tegra A)
sudo ip link set canX type can bitrate 500000
or can1 if you are on Tegra Bsudo ip link set up can0
cangen can0
(on another terminal)candump can0
Send random messages to can bus A-D :
cd /usr/local/driveworks/bin/
sudo ./sample_canbus_logger --driver=can.aurix --params=ip=10.42.0.146,bus=a --hwtime=0 --send_i_understand_implications=1000
You can see specifications of this sample here :
https://docs.nvidia.com/drive/driveworks-4.0/dwx_canbus_logger_sample.html
Send a specific message to can bus A-D :
cd /usr/local/driveworks/bin/
sudo ./sample_canbus_cansend --driver=can.aurix --params=ip=10.42.0.146,bus=a --hwtime=0 --send_i_understand_implications=1000 --send_id=90 --data=0123456789ABCDEF
Send a can frame to can bus A-F :
- From Home :
./cansend_function
Reading can messages :
Can messages can be read by using CANoe software on Windows.
Sending CAN messages from Aurix
(On host PC)
- Connect to PX2 via USB 2.0 host hub
- Use
sudo minicom -D /dev/ttyUSB1
(USB1 for Aurix, USB2 for Tegra A, USB6 for Tegra B) - You can use
cancyclic a on
to generate cyclic frames on can bus A - You can use
cansend a 0x50 0xffff0000 0xaaaa5555
to send a can frame on bus A with ID 0x50 (Aurix)
Different IDs to use for can bus A-F :
Pdu: Dpx_Aurix_Tx_ChnA_80T node: a id: 0x00000050
Pdu: Dpx_TegraA_Tx_ChnA_112T node: a id: 0x00000070
Pdu: Dpx_TegraB_Tx_ChnA_144T node: a id: 0x00000090
Pdu: Dpx_Aurix_Tx_ChnB_81T node: b id: 0x00000051
Pdu: Dpx_TegraA_Tx_ChnB_113T node: b id: 0x00000071
Pdu: Dpx_TegraB_Tx_ChnB_145T node: b id: 0x00000091
Pdu: Dpx_Aurix_Tx_ChnC_82T node: c id: 0x00000052
Pdu: Dpx_TegraA_Tx_ChnC_114T node: c id: 0x00000072
Pdu: Dpx_TegraB_Tx_ChnC_146T node: c id: 0x00000092
Pdu: Dpx_Aurix_Tx_ChnD_83T node: d id: 0x00000053
Pdu: Dpx_TegraA_Tx_ChnD_115T node: d id: 0x00000073
Pdu: Dpx_TegraB_Tx_ChnD_147T node: d id: 0x00000093
Pdu: Dpx_Aurix_Tx_ChnE_84T node: e id: 0x00000054
Pdu: Dpx_TegraA_Tx_ChnE_116T node: e id: 0x00000074
Pdu: Dpx_TegraB_Tx_ChnE_148T node: e id: 0x00000094
Pdu: Dpx_Aurix_Tx_ChnF_85T node: f id: 0x00000055
Pdu: Dpx_TegraA_Tx_ChnF_117T node: f id: 0x00000075
Pdu: Dpx_TegraB_Tx_ChnF_149T node: f id: 0x00000095
Reading messages :
To see if the messages are received, open CANoe on Windows PC, start the simulation and open the TRACE window.
CAN sender app
Description
This application allows a CAN frame to be sent from one of the two Tegra units and read out via CANoe on another Windows computer.
Prerequisites
For use this application , we need SDK Manager with a complete host and target deployed SDK version.(neccesary 120 GB of free disk space)
Installation
You can use this link for download it : https://developer.nvidia.com/drive/downloads#?tx=$product,drive_px2
The user guide : https://docs.nvidia.com/drive/archive/5.1.0.2L/sdkm/download-run-sdkm/index.html
After installation, launch it with sdkmanager --archivedversions
Follow this wiki to step 4 and skip the rest: https://github.com/AD-EYE/To_be_deleted_AD-EYE_Core-Docs-Tmp/blob/master/drive_px2_guides/2_Reset-DPX2.md
Instructions
(On Host PC)
Create a new file to send CAN frame :
- Go to
cd $HOME/ros2can/ros2can-master/cansend_app/src
- Create a directory
your_directory
with your code and a CMakeList (ex : cansend_function) and adapt it - Add your sub-directory into the CMakeList.txt in
$HOME/ros2can/ros2can-master/cansend_app
Instructions for compile :
Only cross-compilation is supported. Before building do prerequisite steps as described in Cross-Compiling for the NVIDIA DRIVE Platform (Linux)
Building your code :
- Go to
cd $HOME/ros2can/ros2can-master/cansend_app
- Create a build folder and go into
mkdir build
- Execute
cmake ..
- Build with the following command :
make install
- You can find your executable file in
$HOME/ros2can/ros2can-master/cansend_app/install/bin
(On Tegra)
Running the code :
- Copy your executable file where you want and modify the permission with
sudo chmod 777 your_executable
- Run it with
./your_executable
If sending frames to can0 (e) or can1 (f), do
sudo ip link set can0 type can bitrate 500000
sudo ip link set up can0
Reading frames :
- Start simulation
- Frames sent will be displayed in Trace window