Thank you so much for your kind support. It is great to learn that SN65HVD230 works fine with TX2 CAN 500kbps communication.
Regarding my test issue. In order to make my question clearly, I list my TX2 setup and test sequence below:
My TX2 setup:
a. Added MTTCAN as a module, rebuilt kernel
b. Installed SocketCAN
c. Connected CAN0 and CAN1 with CAN transceivers as in attached picture:
Load below modules:
a. $ sudo modprobe can
b. $ sudo modprobe can_raw
c. $ sudo modprobe can_dev
d. $ sudo modprobe mttcan
Configure CAN0 and CAN1:
a. $ sudo ip link set can0 type can bitrate 500000
b. $ sudo ip link set up can0
c. $ sudo ip link set can1 type can bitrate 500000
d. $ sudo ip link set up can1
Check CAN0 and CAN1 with âip âdetails link show can*â, both are in ERROR-WARNING state.
Open a terminal and set CAN1 to â$ candump can1â
Open another terminal, and set CAN0 to send data using â$ cansend can0 123#112233â or âcangen can0â
Check terminal which set â$candump can1â previously, it doesnât show any signal.
Check CAN0 and CAN1 with âip âdetails link show can*â again, CAN0 went to BUS-OFF state and CAN1 went to ERROR-PASSIVE state.
Do you see any issues with my tests? Could you give me some hints?
It is unlikely since I checked the connection multiple times. However, I will double check again and come back to you. In the meantime, please share if you come with any other ideas.
I double checked my connection and soldering. The tests still failed.
I wonder what exact CAN transceiver do you use? I use CJMCU-230 with SN65HVD230 (marked as VP230 61M CTCVG4) on its package. It is configured to slope control mode with a 10k resistor. Have you done any changes to your CAN transceiver to make the CAN communication working?
What is length of your CAN bus? Do you need to add any termination resistor to your can bus?
I look forward to hearing from you soon. Thank you so much.
I am also using CJMCU-230 with SN65HVD230.
Have a look at attached image for same.
I faced similar issue while connecting transceiver on breadboard using the connector which was supplied along with the transceiver.
We found it working fine after properly soldering and placing on the breadboard.
And you donât have to configure with 10K resistor/termination resistor as that is there as part of the SoC - CJMCU-230.
Please check with the attachment and let us know if are you using it same way.
Also check the CAN Bus status when in ideal state (before transmitting/receiving the packets).
I finally figured out the route cause in my test setup. It turns out that there are some issues in the CAN transceivers that I used (CJMCU-230 PCBs). One obvious issue is that the CJMCU-230 PCBs have wrong resistor values of both resistors on it. After replacing them with same products from a different vendor supply, the tests passed.
I apologize for the inconvenience that I may caused and would like to thank you again for all your kind support.
Is there any automatic way to do the ip link on boot up? So I can do âcandump can0â right after boot up Ans: Yes it can be automated during boot up sequence.
You can check the feasibility to add the same code snippet to any of the init scripts
or
you can also add it to the bash script - ~/.bashrc (particular user can avail it)
Is there any way to get the can data from python code?
Yes it is possible to code in python for this.
Right now I donât understand python.
I wish someone will get in touch regarding the python code snippet to do this work.
Iâve followed Spatraâs post and rebuilt the kernel and ran all of the set-up commands from the post.
I do see can0 and can1 with ifconfig -a but I donât see anything on either port with candump can0 when I run cansend can0 123#abcdabcd
Should I be expecting the same thing as when I try the same thing over vcan0, running cansend or cangen over that interface and seeing the messages over candump?
I see that the state is at BUS-OFF instead of ERROR-WARNING⊠Did I miss something in my setup?
Or does this only work when I have the transceiver set up first? Even if I am only checking the same interface where I did cansend to?
UPDATE
Finally got it working by playing around with the TX2 and rebooting the system, CAN0/1 finally went to the ERROR-WARNING state instead of BUS-OFF. Once I hooked it up with CAN transceivers and tested on both 500K and 250K network, I was able to read the outputs with candump, and the state became ERROR-ACTIVE. My cansend messages also showed up once that happened. So it does require some CAN activities for it to switch to the proper state.
Thank you for the update and great that it started working.
Do note that you can also do various activities with respect to CAN packets (i.e. receiving only on interested packet types, generating special CAN packets etc) on the network using cangen utility.
The right way to do this on Linux with systemd is to generate âunitâ files that bring up the interfaces, and then make your boot target depend on those units (services.) That way, you can get automatic restart if there are services you depend on, logging for the specific interface is inspectable with journalctl, and so forth.
Another way that can work as well is to add the interfaces, and their settings, to the /etc/network/interfaces file or a file in the /etc/network/interfaces.d directory. This still lets the networking subsystem know about the interfaces earlier in the boot than if you ran a âscriptâ to do so.
Putting the functions in a .bashrc file may be convenient very early in development, but is generally a really bad idea for any kind of system youâre trying to actually build a ârealâ embedded image for.
If the can transceiver is not correctly connected or is incompatible, will there still be activity on the TX line when using a command like âcansend can0 xxx#xxxxxxxxâ?
I believe the corrent behavior when seeing bad CAN transcievers is to turn off the interface, to isolate the device from a possibly broken bus. So, no, I might not expect to see pins âwiggleâ if the transciever is incorrectly connected.
I run according to your opinion.
I try to install SocketCAN and modify tegra18_defconfig.
Also, I command
sudo modprobe can
sudo modprobe mttcan
sudo ip link set can0 type can bitrate 500000
sudo ip link set up can0
I can see CAN communication when I type âifconfigâ