unable to comm w/ device on ubuntu 16.04

CAN FD and LIN Interface for High-Speed USB 2.0

unable to comm w/ device on ubuntu 16.04

Postby andrewdisp » Wed 11. Oct 2017, 02:42

I'm trying to communicate w/ http://leddartech.com/modules/leddarvu/ on ubuntu 16.04 using http://www.peak-system.com/PCAN-USB-Pro ... .html?&L=1:

Code: Select all
$ lsb_release -a
No LSB modules are available.
Distributor ID:   Ubuntu
Description:   Ubuntu 16.04.3 LTS
Release:   16.04
Codename:   xenial
$ uname -a     
Linux ai-P65-P67RGRERA 4.4.0-040400-generic #201601101930 SMP Mon Jan 11 00:32:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

when i connect PCAN-USB Pro FD it is identified fine:

Code: Select all
$ dmesg -wH
...
[  +4.148002] usb 1-1: new high-speed USB device number 36 using xhci_hcd                           
[  +0.128854] usb 1-1: config 1 interface 0 altsetting 0 bulk endpoint 0x83 has invalid maxpacket 64
[  +0.000008] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x84 has invalid maxpacket 64
[  +0.000003] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 64
[  +0.000004] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x85 has invalid maxpacket 64
[  +0.000003] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x5 has invalid maxpacket 64
[  +0.000003] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x86 has invalid maxpacket 64
[  +0.000004] usb 1-1: config 1 interface 1 altsetting 0 bulk endpoint 0x6 has invalid maxpacket 64
[  +0.000422] usb 1-1: New USB device found, idVendor=0c72, idProduct=0011                         
[  +0.000006] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0                     
[  +0.000004] usb 1-1: Product: PCAN-USB Pro FD                                                     
[  +0.000003] usb 1-1: Manufacturer: PEAK-System Technik GmbH                                       
[  +0.006218] peak_usb 1-1:1.0: PEAK-System PCAN-USB Pro FD v2 fw v2.1.0 (2 channels)               
[  +0.000214] peak_usb 1-1:1.0 can0: attached to PCAN-USB Pro FD channel 0 (device 4294967295)     
[  +0.000267] peak_usb 1-1:1.0 can1: attached to PCAN-USB Pro FD channel 1 (device 4294967295)     
[  +8.171873] IPv6: ADDRCONF(NETDEV_CHANGE): can0: link becomes ready                               

and i can now create network interface for it:

Code: Select all
$ sudo ip link set can0 up type can bitrate 500000                                     
$ sudo ip link set up can0

but if i send a CAN frame to start streaming data from this device:

Code: Select all
$ cansend can0 740#0300000000000000

i see this error:

Code: Select all
$ candump can0,0:0,#FFFFFFFF -ace
  can0  740   [8]  03 00 00 00 00 00 00 00   '........'     
  can0  20000004   [8]  00 08 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}     
  can0  20000004   [8]  00 20 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-passive}     

and PCAN-USB Pro FD blinks red.

however keeping everything the same but using http://www.peak-system.com/PCAN-USB.199.0.html?L=1 instead communication works fine.

also if i plug same hardware configuration into windows and use PCAN-View to send frames communication works fine so i think i am not configuring the network interface correctly for PCAN-USB Pro FD:

Code: Select all
$ sudo ip link set can0 up type can bitrate 500000                                     
$ sudo ip link set up can0

Are there more settings i need to communicate w/ this non-FD CAN device?

Thanks for any help,
Andrew
andrewdisp
 
Posts: 3
Joined: Wed 11. Oct 2017, 02:15

Re: unable to comm w/ device on ubuntu 16.04

Postby S.Grosjean » Wed 11. Oct 2017, 11:21

Hello Andrew,

Due to higher clock frequencies, with CAN-FD equipment, you should use the "sample-point 0.xxx" option of "ip link set".

First, plug the PCAN-USB, do the setup of the can interface, then type:
Code: Select all
$ ip -s -d link show can0

Note the "sample-point" value displayed, near to "bitrate xxx". Then, plug the CAN-FD equipment and setup the bitrate with the same sample-point.

For example, if the above command says:
Code: Select all
bitrate 500000 sample-point 0.875

Then type:
Code: Select all
$ ip link set can0 up type can bitrate 5000000 sample-point 0.875

Tip: you don't need to set the can0 interface up again, as you do...

Regards,

Stéphane
User avatar
S.Grosjean
Software Development
Software Development
 
Posts: 143
Joined: Wed 4. Jul 2012, 17:02

Re: unable to comm w/ device on ubuntu 16.04

Postby andrewdisp » Wed 11. Oct 2017, 19:39

Hello Stéphane,

Thanks for your help and work on the Linux driver.

I tried explicitly setting the sample-point but it does not seem to fix my error. If i create network interface w/o specifying sample-point i see e.g.:

Code: Select all
$ sudo ip link set can0 up type can bitrate 500000
$ ip -s -d link show can0
82: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 500000 sample-point 0.875
          tq 50 prop-seg 17 phase-seg1 17 phase-seg2 5 sjw 1
          pcan_usb_pro_fd: tseg1 1..64 tseg2 1..16 sjw 1..16 brp 1..1024 brp-inc 1
          pcan_usb_pro_fd: dtseg1 1..16 dtseg2 1..8 dsjw 1..4 dbrp 1..1024 dbrp-inc 1
          clock 80000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          0          0          0          0          0         
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns
    0

i then reconnect the adapter and this time specify sample-point 0.875 (i assume you meant bitrate 500000 not 5000000):

Code: Select all
$ sudo ip link set can0 up type can bitrate 500000 sample-point 0.875
$ ip -s -d link show can0
84: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
          bitrate 500000 sample-point 0.875
          tq 50 prop-seg 17 phase-seg1 17 phase-seg2 5 sjw 1
          pcan_usb_pro_fd: tseg1 1..64 tseg2 1..16 sjw 1..16 brp 1..1024 brp-inc 1
          pcan_usb_pro_fd: dtseg1 1..16 dtseg2 1..8 dsjw 1..4 dbrp 1..1024 dbrp-inc 1
          clock 80000000
          re-started bus-errors arbit-lost error-warn error-pass bus-off
          0          0          0          0          0          0         
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0

which seems ~ same to me and candump reports comm error as before:

Code: Select all
$ candump can0,0:0,#FFFFFFFF -ace             
  can0  740   [8]  03 00 00 00 00 00 00 00   '........'     
  can0  20000004   [8]  00 08 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}     
  can0  20000004   [8]  00 20 00 00 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-passive}     

whenever i send can frame to start streaming from device:

Code: Select all
$ cansend can0 740#0300000000000000

again all works w/ non FD adapter (http://www.peak-system.com/PCAN-USB.199.0.html?L=1) so i think you are right that there is some FD comm related setting i need to use but i'm not sure which in addition to this sample-point.

Thanks,
Andrew
andrewdisp
 
Posts: 3
Joined: Wed 11. Oct 2017, 02:15

Re: unable to comm w/ device on ubuntu 16.04

Postby S.Grosjean » Thu 12. Oct 2017, 11:05

Hello Andrew,

Please re-check your procedure:
Capture.JPG
Capture.JPG (27.25 KiB) Viewed 56 times

I had asked to first read the sample-point from can0 when can0 corresponds to the PCAN-USB. According to your code, AFAIU you first had a look to the current sample-point of the PCAN-USB Pro FD. So your commands didn't change anything: you have setup the same sample-point value to the same device.

Regards,

Stéphane
User avatar
S.Grosjean
Software Development
Software Development
 
Posts: 143
Joined: Wed 4. Jul 2012, 17:02

Re: unable to comm w/ device on ubuntu 16.04

Postby andrewdisp » Thu 12. Oct 2017, 19:05

Hello Stéphane,

Sorry, I did that wrong. Here is what PCAN-USB says:
Code: Select all
$ sudo ip link set can0 up type can bitrate 500000
$ ip -s -d link show can0
99: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state ERROR-ACTIVE restart-ms 0
     bitrate 500000 sample-point 0.875
     tq 125 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
     pcan_usb: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
     clock 8000000
     re-started bus-errors arbit-lost error-warn error-pass bus-off
     0          0          0          0          0          0         
    RX: bytes  packets  errors  dropped overrun mcast   
    0          0        0       0       0       0       
    TX: bytes  packets  errors  dropped carrier collsns
    0          0        0       0       0       0       

so it has sample-point 0.875. this is the same sample-point used by PCAN-USB FD from above.

Thanks,
Andrew
andrewdisp
 
Posts: 3
Joined: Wed 11. Oct 2017, 02:15

Re: unable to comm w/ device on ubuntu 16.04

Postby M.Maidhof » Mon 16. Oct 2017, 10:52

Hi,

please use a different clock setting for the 500k. Best solution is to use the same settings as under Windows with PCAN-View, using 24Mhz:

Bitrates.JPG
Bitrates.JPG (55.3 KiB) Viewed 26 times


regards

Michael
M.Maidhof
Support
Support
 
Posts: 804
Joined: Wed 22. Sep 2010, 14:00
Location: Darmstadt, Germany


Return to PCAN-USB Pro FD



cron