How to test CANbus on TX2

I just want to test the canbus of tx2 after I flashed OS and installed SDKmanager
detail:
JetPack4.2.2(rev.1)
CUDA v10.0
cuDNN v7.5
TensorRT v5.1
OpenCV v3.3.1
VisionWorks v1.6
Multimedia API v32.2

I use two TJA1050 canbus transceive,one TJA1050’s tx pin connect to J26 PIN#5, rx pin—J26 PIN#7,the other TJA1050’s tx pin —J26 PIN#15, rx pin —J26 PIN#17, power supply connects to PIN#8 and PIN#10,both TJA1050 transceive have 120R resistance and i have used them in the canbus

the commands typed in the terminal:

cd /lib/modules/4.9.140-tegra/kernel/net/can
sudo insmod can.ko
sudo insmod can-raw.ko
sudo insmod can-gw.ko
sudo insmod can-bcm.ko
cd /lib/modules/4.9.140-tegra/kernel/drivers/net/can
sudo insmod can-dev.ko
sudo insmod slcan.ko
sudo insmod vcan.ko
cd ./mttcan/native
sudo insmod mttcan.ko

hld@hld-desktop:~$ lsmod
Module Size Used by
mttcan 66187 0
vcan 3230 0
slcan 7266 0
can_dev 13306 1 mttcan
can_bcm 16471 0
can_gw 10919 0
can_raw 10388 0
can 46600 3 can_raw,can_bcm,can_gw
bnep 16562 2
fuse 103841 3
zram 26166 6
overlay 48691 0
bcmdhd 934274 0
cfg80211 589351 1 bcmdhd
nvgpu 1569917 37
bluedroid_pm 13912 0
ip_tables 19441 0
x_tables 28951 1 ip_tables

sudo ip link set can0 type can bitrate 500000
sudo ip link set can1 type can bitrate 500000
sudo ip link set up can0
sudo ip link set up can1

hld@hld-desktop:~$ ifconfig
can0: flags=193<UP,RUNNING,NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 131

can1: flags=193<UP,RUNNING,NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 132

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.108 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a05c:1930:7005:396b prefixlen 64 scopeid 0x20
ether 00:04:4b:de:3f:1b txqueuelen 1000 (Ethernet)
RX packets 1069 bytes 857673 (857.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1240 bytes 170430 (170.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 41

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 455 bytes 69570 (69.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 455 bytes 69570 (69.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

rndis0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether de:fd:5f:cc:40:a1 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

usb0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether de:fd:5f:cc:40:a3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

In one terminal ,I wrote:
cansend can0 123#1122334455667788

In another termianl:
sudo candump can1

But I can’t recieved any words in the can1 termianl

please tell me where is wrong ,how can I test the canbus.

thank you very much!

hld@hld-desktop:~$ cansend can0 123#1122334455667788
hld@hld-desktop:~$ cansend can0 123#1122334455667788
hld@hld-desktop:~$ ifconfig
can0: flags=129<UP,NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 3 bytes 24 (24.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 131

can1: flags=193<UP,RUNNING,NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 132

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.108 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a05c:1930:7005:396b prefixlen 64 scopeid 0x20
ether 00:04:4b:de:3f:1b txqueuelen 1000 (Ethernet)
RX packets 10552 bytes 5748013 (5.7 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11695 bytes 2163006 (2.1 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 41

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1 (Local Loopback)
RX packets 1036 bytes 130684 (130.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1036 bytes 130684 (130.6 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

rndis0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether de:fd:5f:cc:40:a1 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

usb0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether de:fd:5f:cc:40:a3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Hi,

Your connections are wrong.
Please connect Rx of Transceiver to Rx pin on J26 and similarly for Tx. You have connected it opposite. Connect Power-supply to Pin 2(3.3V) instead of pin 8(5V)
Let me know if you find any further issues.

Thanks,
Shubhi

Oh, sorry,I have described it wrong, I surely confirm that I have connected Rx of Transceiver to Rx pin on J26 and similarly for Tx as your command, then I changed Power-supply to Pin 2(3.3V) instead of pin 8(5V), but it can’t receive any data either.
I have found someone had used this method:
1.​CONFIG_MTTCAN = m
2.modprobe can
3.modprobe can_raw
4.modprobe mttcan
5.sudoip link set can0 type can bitrate 500000
sudoip link set can1 type can bitrate 500000

sudoip link set up can0
sudoip link set up can1

candump can0
cansend can1 1F334455#1122334455667788

I don’t konw is there any diffierence between my solution and his.
Otherwise, can you speak Chinese? I am not good at English,so many ideas can’t be decribed very well

Otherwise, I typed command “sudo apt-get install can-utils” in the terminal and it showed"can-utils has be installed already", but when I typed command “canconfig” in the terminal it showed “bash:canconfig:command not found”, I don’t know how to solute this problem

Hi,

Sorry, I don’t know Chinese. If you are not able to understand my comments in English, I will figure out some way to convert it into Chinese. Let me know when you are facing difficulties in understanding.

Make sure you have made proper connections, properly connected CAN BUS HIGH and LOW pins. I see your connection diagram, you have shorted two pins, maybe there you have to connect CAN bus. Please recheck where you have connected CAN Bus pins.

These are the only steps you have to do to enable CAN:
modprobe can
modprobe can-dev
modprobe mttcan

ip link set can0 type can bitrate 500000
ip link set can0 up

ip link set can1 type can bitrate 500000
ip link set can1 up

In other terminal, run below command
candump can1
then run
cansend can0 123#abcdabcd

Thanks,
Shubhi

Hi Shubhi,I surely have shorted canH and canL, I thought those two pins are the switch to chose CANbus terminal resistance. I succeeded under your professional guidance, thank you very much!