CanBus on Jetson Nano

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
ntesla
Posts: 4
Joined: Wed 8. Jul 2020, 13:42

CanBus on Jetson Nano

Post by ntesla » Wed 8. Jul 2020, 14:14

Hi,
I have this product https://www.peak-system.com/PCAN-USB.199.0.html?&L=1
I am trying to implement some computer vision applications with jetson nano but I couldn't figure out how the car will communicate with the Jetson nano.
This command doesnt give any response lsmod | grep ^peak
I installed the driver with the following steps:
1. Download Peak linux driver 8.10.2
2. make all
3. sudo make install
4. sudo modprobe pcan
5. cat /proc/pcan This command gives exactly the same thing with the instruction

Code: Select all

*------------- PEAK-System CAN interfaces (www.peak-system.com) -------------
*------------- Release_20200701_n (8.10.2) Jul  8 2020 08:29:20 --------------
*------------------- [mod] [isa] [pci] [pec] [dng] [usb] --------------------
*--------------------- 1 interfaces @ major 505 found -----------------------
*n -type- -ndev- --base-- irq --btr- --read-- --write- --irqs-- -errors- status
32    usb   -NA- ffffffff 000 0x001c 00000000 00000000 00000000 00000000 0x0000
6. /usr/local/bin/receivetest

Code: Select all

receivetest Version "Release_20150611_n"  (www.peak-system.com)
------- Copyright (C) 2004-2009 PEAK System-Technik GmbH ------
receivetest comes with ABSOLUTELY NO WARRANTY.     This is free
software  and you are welcome  to redistribute it under certain
conditions.   For   details   see    attached   COPYING   file.
receivetest: device node="/dev/pcan0"
Only standard frames are accepted, init with 500 kbit/sec.
receivetest: can't open /dev/pcan0
receivetest: finished (2): 0 message(s) received

7.Download PCAN-Basic_Linux-4.3.4
8. make all
9. sudo make install
10. sudo apt-get install python3-tk
11. sudo apt-get install tix
12. sudo apt-get install g++
13. sudo apt-get install gtk+2.0
14. Download the PCAN view linux gtk
15. make all
16. pcanview (I can receive the message successfully)
Image
17. I use this code: http://python-can.readthedocs.io/en/master/
When I try to send message using python it gives this error:

Code: Select all

raise NotImplementedError('Invalid CAN Bus Type - {}'.format(config['interface']))
NotImplementedError: Invalid CAN Bus Type - None

And also I can't see can0 when I type ifconfig in terminal. I want to send the message using Python what should I do to solve this problems?

Thanks

ntesla
Posts: 4
Joined: Wed 8. Jul 2020, 13:42

Re: CanBus on Jetson Nano

Post by ntesla » Thu 9. Jul 2020, 08:40

Okay I saw this post and I uninstalled the linux driver. Now I can see can0 when I type ifconfig -a

Code: Select all

can0: flags=128<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
And Here the output of the dmesg | grep usb

Code: Select all

[    0.000000] Kernel command line: tegraid=21.1.2.0.0 ddr_die=4096M@2048M section=512M memtype=0 vpr_resize usb_port_owner_info=0 lane_owner_info=0 emc_max_dvfs=0 touch_id=0@63 video=tegrafb no_console_suspend=1 console=ttyS0,115200n8 debug_uartport=lsport,0 earlyprintk=uart8250-32bit,0x70006000 maxcpus=4 usbcore.old_scheme_first=1 lp0_vec=0x1000@0xff780000 core_edp_mv=1125 core_edp_ma=4000  root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0    root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0 quiet
[    0.437791] iommu: Adding device 70090000.xusb to group 2
[    0.508193] vdd-usb-vbus: supplied by vdd-5v0-sys
[    0.508251] vdd-usb-vbus: 5000 mV 
[    0.508832] vdd-usb-vbus2: 5000 mV 
[    0.554993] usbcore: registered new interface driver usbfs
[    0.555039] usbcore: registered new interface driver hub
[    0.555104] usbcore: registered new device driver usb
[    0.629019] vdd-usb-vbus2: supplied by vdd-3v3-sys
[    0.630905] vdd-usb-hub-en: supplied by vdd-1v8-sys
[    0.630939] vdd-usb-hub-en: 5000 mV 
[    0.970749] tegra-xusb-padctl 7009f000.xusb_padctl: TEGRA_FUSE_SKU_CALIB_0 = 0x81e7c0f
[    0.970759] tegra-xusb-padctl 7009f000.xusb_padctl: TEGRA_FUSE_USB_CALIB_EXT_0 = 0x4
[    0.972417] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-usb2.0, lane = usb2-0, function = xusb
[    0.972526] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-usb2.1, lane = usb2-1, function = xusb
[    0.972619] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-usb2.2, lane = usb2-2, function = xusb
[    0.972808] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.3, lane = pcie-0, function = pcie-x1
[    0.972892] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.4, lane = pcie-1, function = pcie-x4
[    0.972983] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.5, lane = pcie-2, function = pcie-x4
[    0.973073] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.6, lane = pcie-3, function = pcie-x4
[    0.973186] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.7, lane = pcie-4, function = pcie-x4
[    0.973270] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.8, lane = pcie-5, function = xusb
[    0.973362] tegra-xusb-padctl 7009f000.xusb_padctl: dev = phy-pcie.9, lane = pcie-6, function = xusb
[    1.669429] usbcore: registered new interface driver r8152
[    1.669475] usbcore: registered new interface driver asix
[    1.669533] usbcore: registered new interface driver ax88179_178a
[    1.669574] usbcore: registered new interface driver cdc_ether
[    1.669620] usbcore: registered new interface driver net1080
[    1.669667] usbcore: registered new interface driver cdc_subset
[    1.669704] usbcore: registered new interface driver zaurus
[    1.669760] usbcore: registered new interface driver cdc_ncm
[    1.674024] tegra-xusb 70090000.xusb: USB2 port 0 has OTG_CAP
[    1.674636] tegra-xusb-padctl 7009f000.xusb_padctl: enabled OTG on UTMI pad 0
[    1.675843] tegra-xusb 70090000.xusb: extcon 0: ffffffc0fa5d1000 id
[    1.677078] usbcore: registered new interface driver uas
[    1.677137] usbcore: registered new interface driver usb-storage
[    1.677278] usbcore: registered new interface driver usbserial
[    1.682350] tegra-xusb 70090000.xusb: Firmware timestamp: 2019-10-17 15:58:59 UTC, Version: 50.25 release
[    1.682411] tegra-xusb 70090000.xusb: xHCI Host Controller
[    1.682440] tegra-xusb 70090000.xusb: new USB bus registered, assigned bus number 1
[    1.683218] tegra-xusb 70090000.xusb: hcc params 0x0184f525 hci version 0x100 quirks 0x00050010
[    1.683243] usbcore: registered new interface driver xpad
[    1.683282] tegra-xusb 70090000.xusb: irq 61, io mem 0x70090000
[    1.683577] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.683583] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.683588] usb usb1: Product: xHCI Host Controller
[    1.683593] usb usb1: Manufacturer: Linux 4.9.140-tegra xhci-hcd
[    1.683597] usb usb1: SerialNumber: 70090000.xusb
[    1.685020] tegra-xusb 70090000.xusb: xHCI Host Controller
[    1.685033] tegra-xusb 70090000.xusb: new USB bus registered, assigned bus number 2
[    1.685123] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    1.685230] usb usb2: New USB device found, idVendor=1d6b, idProduct=0003
[    1.685236] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.685240] usb usb2: Product: xHCI Host Controller
[    1.685244] usb usb2: Manufacturer: Linux 4.9.140-tegra xhci-hcd
[    1.685249] usb usb2: SerialNumber: 70090000.xusb
[    1.786356] tegra-xusb-padctl 7009f000.xusb_padctl: power on UTMI pads 1
[    1.786416] tegra-xusb-padctl 7009f000.xusb_padctl: power on UTMI pads 2
[    1.894435] usbcore: registered new interface driver usbhid
[    1.894436] usbhid: USB HID core driver
[    1.900111] usbcore: registered new interface driver snd-usb-audio
[    2.010335] usb 1-2: new high-speed USB device number 2 using tegra-xusb
[    2.029695] vdd-usb-vbus: disabling
[    2.029698] vdd-usb-vbus2: disabling
[    2.029789] vdd-usb-hub-en: disabling
[    2.039338] usb 1-2: New USB device found, idVendor=0bda, idProduct=5411
[    2.039343] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    2.039347] usb 1-2: Product: 4-Port USB 2.1 Hub
[    2.039350] usb 1-2: Manufacturer: Generic
[    2.162342] usb 1-3: new full-speed USB device number 3 using tegra-xusb
[    2.184453] usb 1-3: New USB device found, idVendor=8087, idProduct=0a2b
[    2.184459] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.330300] usb 1-2.1: new low-speed USB device number 4 using tegra-xusb
[    2.370978] usb 1-2.1: New USB device found, idVendor=03f0, idProduct=034a
[    2.370983] usb 1-2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    2.370987] usb 1-2.1: Product: HP Elite USB Keyboard
[    2.370989] usb 1-2.1: Manufacturer: Chicony
[    2.380883] input: Chicony HP Elite USB Keyboard as /devices/70090000.xusb/usb1/1-2/1-2.1/1-2.1:1.0/0003:03F0:034A.0001/input/input2
[    2.438624] hid-generic 0003:03F0:034A.0001: input,hidraw0: USB HID v1.10 Keyboard [Chicony HP Elite USB Keyboard] on usb-70090000.xusb-2.1/input0
[    2.448370] input: Chicony HP Elite USB Keyboard as /devices/70090000.xusb/usb1/1-2/1-2.1/1-2.1:1.1/0003:03F0:034A.0002/input/input3
[    2.506522] hid-generic 0003:03F0:034A.0002: input,hidraw1: USB HID v1.10 Device [Chicony HP Elite USB Keyboard] on usb-70090000.xusb-2.1/input1
[    2.586291] usb 1-2.3: new full-speed USB device number 5 using tegra-xusb
[    2.614923] usb 1-2.3: New USB device found, idVendor=045e, idProduct=07fd
[    2.614928] usb 1-2.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    2.614931] usb 1-2.3: Product: Microsoft Nano Transceiver 1.1
[    2.614934] usb 1-2.3: Manufacturer: Microsoft
[    2.617801] input: Microsoft Microsoft Nano Transceiver 1.1 as /devices/70090000.xusb/usb1/1-2/1-2.3/1-2.3:1.0/0003:045E:07FD.0003/input/input4
[    2.674660] hid-generic 0003:045E:07FD.0003: input,hidraw2: USB HID v1.11 Keyboard [Microsoft Microsoft Nano Transceiver 1.1] on usb-70090000.xusb-2.3/input0
[    2.678669] input: Microsoft Microsoft Nano Transceiver 1.1 as /devices/70090000.xusb/usb1/1-2/1-2.3/1-2.3:1.1/0003:045E:07FD.0004/input/input5
[    2.738498] hid-generic 0003:045E:07FD.0004: input,hidraw3: USB HID v1.11 Device [Microsoft Microsoft Nano Transceiver 1.1] on usb-70090000.xusb-2.3/input1
[    2.740491] input: Microsoft Microsoft Nano Transceiver 1.1 as /devices/70090000.xusb/usb1/1-2/1-2.3/1-2.3:1.2/0003:045E:07FD.0005/input/input6
[    2.740799] hid-generic 0003:045E:07FD.0005: input,hidraw4: USB HID v1.11 Mouse [Microsoft Microsoft Nano Transceiver 1.1] on usb-70090000.xusb-2.3/input2
[    2.822296] usb 1-2.4: new full-speed USB device number 6 using tegra-xusb
[    2.843457] usb 1-2.4: New USB device found, idVendor=0c72, idProduct=000c
[    2.843463] usb 1-2.4: New USB device strings: Mfr=10, Product=4, SerialNumber=0
[    2.843467] usb 1-2.4: Product: PCAN-USB
[    2.843471] usb 1-2.4: Manufacturer: PEAK-System Technik GmbH
[    4.966005] usb0: HOST MAC be:68:e4:64:c4:de
[    4.966040] usb0: MAC be:68:e4:64:c4:df
[    4.995299] l4tbr0: port 2(usb0) entered blocking state
[    4.995304] l4tbr0: port 2(usb0) entered disabled state
[    4.995617] device usb0 entered promiscuous mode
[    5.004373] IPv6: ADDRCONF(NETDEV_UP): usb0: link is not ready
[    5.846484] tegra-xusb 70090000.xusb: Upgrade port 0 to USB3.0
[    5.846491] tegra-xusb 70090000.xusb: Upgrade port 1 to USB3.0
[    6.173720] usbcore: registered new interface driver btusb
[    6.174229] usb 2-1: new SuperSpeed USB device number 2 using tegra-xusb
[    6.199313] usb 2-1: New USB device found, idVendor=0bda, idProduct=0411
[    6.199320] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    6.199325] usb 2-1: Product: 4-Port USB 3.1 Hub
[    6.199328] usb 2-1: Manufacturer: Generic
[    6.362299] usb 2-1: usb_suspend_both: status 0
[    6.362501] usb usb2: usb_suspend_both: status 0
[    6.588250] peak_usb 1-2.4:1.0: PEAK-System PCAN-USB adapter hwrev 84 serial FFFFFFFF (1 channel)
[    6.588623] peak_usb 1-2.4:1.0 can0: attached to PCAN-USB channel 0 (device 255)
[    6.588716] usbcore: registered new interface driver peak_usb


1. The output of the sudo modprobe pcan :

Code: Select all

modprobe: FATAL: Module pcan not found in directory /lib/modules/4.9.140-tegra
2. The output of the python code

Code: Select all

raise NotImplementedError('Invalid CAN Bus Type - {}'.format(config['interface']))
NotImplementedError: Invalid CAN Bus Type - None

User avatar
S.Grosjean
Software Development
Software Development
Posts: 282
Joined: Wed 4. Jul 2012, 17:02

Re: CanBus on Jetson Nano

Post by S.Grosjean » Thu 9. Jul 2020, 10:00

Hi,

receivetest doesn't work since it tries to open /dev/pcan0 (default) while the PCAN-USB CAN channel is implemented by /dev/pcan32.

You should run:

Code: Select all

$ receivetest -f=/dev/pcan32
Regards,
— Stéphane

ntesla
Posts: 4
Joined: Wed 8. Jul 2020, 13:42

Re: CanBus on Jetson Nano

Post by ntesla » Thu 9. Jul 2020, 10:23

After uninstalling linux driver, it doesnt work bash: receivetest: command not found. Does PCAN-USB need peak linux driver?
I just want to send basic messages using python.

User avatar
S.Grosjean
Software Development
Software Development
Posts: 282
Joined: Wed 4. Jul 2012, 17:02

Re: CanBus on Jetson Nano

Post by S.Grosjean » Thu 9. Jul 2020, 10:30

Hi,

receivetest is an example that shows how to use peak-linux-driver (aka the pcan driver). Therefore, if you uninstall this driver, the example can't work. That's mainly the reason why those examples are also removed from the system by the uninstall process. In my opinion, you should first reinstall the driver...

Regards,
— Stéphane

ntesla
Posts: 4
Joined: Wed 8. Jul 2020, 13:42

Re: CanBus on Jetson Nano

Post by ntesla » Thu 9. Jul 2020, 10:49

Which driver should I install netdev or chardev?
Actually I dont think driver is the problem. When I install the driver, can0 doesn't show up in ifconfig which I mentioned above

User avatar
S.Grosjean
Software Development
Software Development
Posts: 282
Joined: Wed 4. Jul 2012, 17:02

Re: CanBus on Jetson Nano

Post by S.Grosjean » Thu 9. Jul 2020, 14:07

Hi,

In order to understand which driver you need, you should first read this page: http://www.peak-system.com/fileadmin/me ... /index.htm.

Next, you could also have a (even quick) look to peak-linux-driver-x.y.y/Documentation/PCAN-Driver-Linux_UserMan_eng.pdf, in which there's a quite good explanation of what are the differences between both netdev and chardev interfaces options.

And finally, it mainly depends on how you expect to build your CAN application over the CAN bus: by using the socket-CAN or the proprietary chardev interface? "peak-linux-driver-x.y.z/test" programs are here to demonstrate how a chardev application works. The netdev interface doesn't need from us any test (or example) applications since the can-utils package made by the linux-can team already exists and proposes quite the same set of tools and utilities. But over the socket-can (aka netdev) interface.

Tip: when dealing with "/dev/pcanX" device node then you must use the pcan driver through the chardev interface. If you want to play with "canX" interfaces, then it's the netdev one. You might use pcan in netdev mode *OR* use the mainline socket-can driver that are part of the kernel you run (see peak_usb in your case). In other words, if your CAN application will be a socket one, then you don't need the peak-linux-driver at all since your kernel includes the peak_usb driver:

Code: Select all

[    6.588250] peak_usb 1-2.4:1.0: PEAK-System PCAN-USB adapter hwrev 84 serial FFFFFFFF (1 channel)
[    6.588623] peak_usb 1-2.4:1.0 can0: attached to PCAN-USB channel 0 (device 255)
Regards,
— Stéphane

Post Reply