Xavier jetson development kit CAN controller test

Hi.
I’m trying to use CAN bus to get data using OBD2.

I have attached 2 CAN transceivers and enabled can0 and can1 with following command.


#check current values of related registers
sudo busybox devmem 0x0c303000
sudo busybox devmem 0x0c303008
sudo busybox devmem 0x0c303010
sudo busybox devmem 0x0c303018
#0x0000C055
#0x0000C055
#0x0000C059
#0x0000C059

#use devmem to modify registers
sudo busybox devmem 0x0c303000 32 0x0000C400
sudo busybox devmem 0x0c303008 32 0x0000C458
sudo busybox devmem 0x0c303010 32 0x0000C400
sudo busybox devmem 0x0c303018 32 0x0000C458

#check modified values of relate registers
sudo busybox devmem 0x0c303000
sudo busybox devmem 0x0c303008
sudo busybox devmem 0x0c303010
sudo busybox devmem 0x0c303018
#0x0000C400
#0x0000C458
#0x0000C400
#0x0000C458

#or use modeprobe to mount CAN controller
sudo modprobe can
sudo modprobe can-raw
sudo modprobe can-dev
sudo modprobe mttcan

#configure CAN controllers with 1Mbps baudrate
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can1 type can bitrate 1000000

#loopback test
sudo ip link set can0 type can bitrate 1000000 loopback on
sudo ip link set can1 type can bitrate 1000000 loopback on

#open CAN controller
sudo ip link set up can0
sudo ip link set up can1

Question 1.
when I am testing on loopback mode, even I didn’t attach 2 CAN transceivers to xavier, why are can0 and can1 detected?

Question 2.
I have configured CAN controllers with 1Mbps baudrate with following command, and sent packet using can-utils. According to “Enabling CAN on Nvidia Jetson Xavier Developer Kit | by Ramin Nabati | Medium” this blog and “GitHub - hmxf/can_xavier: CAN Bus Drive Script to this git” if I send packet using “cansend can1 5A1#1122334455667788” this command, I should receive message on “candump can0”, which looks like “can0 5A1 [8] 11 22 33 44 55 66 77 88” this. But, I am not receiving any messages. What is wrong with it?

Question 3.
I am trying to connect OBD2 to DB9 cable. I have enabled CAN as far as I can, and tried to get CAN packets with wireshark. But I have failed to get packets. Any advise on OBD&CAN? For example is there any software I can use on xavier development kit? Or guide line for CAN and OBD.

Thank you.


this is a terminal when I was testing on loop back mode.

Hi tlcnrrn211,

This is controller loopback testing. It does not need transceiver to connect. It sends message and check the msg and send it back on RX line. So, you must have shorted Tx and Rx of Xavier CAN pins, thus you are receiving the messages. and that means your CAN configurations are all fine as well.
If you are not receiving msgs with transceiver, please double check your connections. Short CANH to CANH and CANL to CANL for bus connection. Also, check 120 ohm termination is there between CANH & CANL. Also, check what stats are saying:
ip -d -s link show can0
ip -d -s link show can1

Let me know the results.

Thanks,
Shubhi

1 Like

Thanks for replying.

upper image is a test I have done "Test two CAN controllers if you have configured hardware transceiver circuit. " “GitHub - hmxf/can_xavier: CAN Bus Drive Script” following this github.

according to this github I should be receiving “can0 5A1 [8] 11 22 33 44 55 66 77 88”. But I’m not receiving it.
Picture below shows ‘ip -d -s link show can0’ and ‘can1’


Upper picture is how I built my CAN transceiver.


Thanks for helping out.

Can you specify more about Short CANH to CANH and CANL to CANL for bus connection & check 120 ohm termination is there between CANH & CANL?

Hi,
Problem may be due to the silver color connector in between the 2 transceivers. From which CANH,CANL is connected.
By shorting , I meant to connect CANH of first transceiver to CANH of second directly and similar with CANL.
But you are connecting one more device, can you tell me what is that device?

1 Like

Oh, I get it.
I’ve shorted CANH to CANH and CANL to CANL.
And I tested and got result as I expected.

With the DB9 connector(silver connector with green, blue, yellow, purple line connected) I’m trying to connect it with OBD2 and get information about Vehicle.
It could be a problem with DB9 connector, so I’m planning to test the connector today. I’ll let you know about it when it is tested.

I’m planning to capture packets from OBD with wireshark.
It there any other software I could use to capture packets from CAN on Xavier?

Thanks for helping me out.

Just checked DB9 connector and it works fine.

So the hardwares are fine, and now I just need to get CAN signals from OBD2.

As soon as I connect OBD2 to DB9 connector should I be getting any CAN signal when I monitor with wireshark?

Or do I have to request any message to get data from OBD?

Thanks a lot

this is the map I’m planning.
Thanks.

You need to follow the J1850 protocol - I guess that’s what that repo you pulled does. You connect CANH, CANL, and ground to the ODB2. You MAY need the 120 termination between CANH and CANL if neither your tranceiver for the can have them.

1 Like

You have to request PIDs to get data from the car. If you ask to read the RPM pid, it will respond quickly with a response.

1 Like

Can you explain more about ‘check 120 ohm termination is there between CANH & CANL’ ?
Thank you

Thanks for answering.
I am using wireshark to capture packets.
I get it that I have to request PIDs to get date from car.
I am follow ISO 15765 protocol.
But if you do, can you tell me more about how to request PIDs, I’m trying to google it but it is not easy to find it.
By meaning requesting PIDs, should I be using cansend can0 5A1#1122334455667788 command such as this?
And if you don’t matter can you explain more about what you mean by saying 120 termination between CANH and CANL?
Thank you for helping me out

A CAN bus always needs termination at at least one end, sometimes both. 120ohm is typical. Check the resistance between CANH and CANL with both ends powered off - it should be around 120o - if it’s not add a resistor to one end.

This is basic CAN stuff.

1 Like

You can certainly determine the remote nodes address and stuff the packet manually to request a value, but usually you buy a J1850 stack that implements the protocol.

This SW you got from github - isn’t that what that does the J1850 protocol? If not, there are python scripts to implement it.

FIRST get the CAN to work. Send out a packet and verify that it gets and ACK back very quickly on a scope - that means electrically the bus is set up correctly - the packet gets sent out repeatedly, then the other end is not connected, or not receiving the packet accurately. Once that works, you can format some J1850 packets and try them with “cansend” or your example program.

1 Like

Thanks. I’ll try and make it work. And then I’ll let you know.
Thanks a lot.

Hi, with simulator using can 2.0 it worked and I got what I expected.
Thanks.

Now I’m gonna connect it to a real vehicle.
But here is what I think is a problem.
I need to use CAN FD on the project I’m doing.
Will this interface work with CAN FD as well?

If it doesn’t should I be changing something?

I guess I need another interface for CAN FD after googling…

Not sure what you mean “simulator” - a Kvaser? If that’s the case, it’s eveidence your network was not set up properly.

Lots of threads on CAN FD .

To make CAN0 FD up on network:
$ip link set can0 up type can bitrate 1000000 dbitrate 2000000 fd on berr-reporting on
To send FD frame from can0:
cansend can0 123##1abcdabcd

Oh I am using ecusim2000 as vehicle simulator.
It is quite old simulator so it doesn’t support CAN FD.
I’ve forgot to put fd on setting.
It works fine.
next week u’m gonna try with real vehicle.
I’ll let you know about it.
Thanks a lot and really appreciate it.

Thanks, Good luck.

1 Like

I’ve got it work, and got result I wanted.
It’s no big deal but a little bit problem. When I get data with CAN, is there a way to change the sample rate of CAN?