Page 1 of 1

PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 09:38
by alexanderg
Hello!
I can not build 'netdev' driver for PCAN-USB device.
The build fails because of CAN_CTRLMODE_FD is not defined in Linux/include/uapi/linux/can/netlink.h. Also I found that a lot of other CAN definitions are lacks in this file.
What is the problem? Can it be "patched"?
'chardev' device can be build without any problems. My full Linux version is:
Linux ubuntu 3.13.0-73-generic #116-Ubuntu SMP Fri Dec 4 15:31:30 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 14:23
by S.Grosjean
Hi,

3.13 is an "old" version, in which there were no support for CAN-FD...

If you plan to use the socket-can interface, why don't you use the mainline driver instead? The PCAN-USB is fully supported by the Kernel in this version, so you don't need to build nor install the pcan (peak-linux-driver-x.y) driver.

Plug your PCAN-USB, then type:

Code: Select all

$ ip -s -d link show type can
You should see something like:

Code: Select all

39: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0
    can state STOPPED restart-ms 0
          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
Regards,

Stéphane

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 14:51
by alexanderg
Hi, Stephane,
Thank you for your response. I tried your solution, it does not work, sorry:

>ip -s link show type can
Error: either "dev" is duplicate, or "can" is a garbage.

Probably, something more to be done.

Alex

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 15:04
by S.Grosjean
Hello,

No, it looks like you're running an old version of "iproute2" package.

So, first, let's retry with:

Code: Select all

$ ifconfig -a
instead.

Regards,

Stéphane

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 15:11
by alexanderg
Hi,

I have checked. No "can" interface in "ifconfig -a" output.
Does it mean, that socket CAN interface is not supported?

Alex.

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 16:42
by S.Grosjean
Hi,

Hem, strange. let's start from scratch with trying to load the module by hand:

Code: Select all

$ sudo modprobe peak_usb
If nothing (no error) displayed, do (be sure that the PCAN-USB is connected to the USB socket!):

Code: Select all

$ dmesg | grep peak_usb
Regards,

Stéphane

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Mon 14. Nov 2016, 16:54
by alexanderg
Hi,
Thank you, Stephane! Now I see 'can0' netdev interface.
I still have an errors ("RTNETLINK answers: Invalid argument") but suppose, its an application problem.
Thank you a lot.

Alex

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Tue 15. Nov 2016, 10:23
by alexanderg
Hi, Stephane
Sorry for troubling you again.
Now I see can0 interface at 'ifconfig -a' output:

Code: Select all

 can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          NOARP  MTU:16  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
So it exist now.
I also checked 'ip -details -statistics link show can0' output:

Code: Select all

3: can0: <NOARP,ECHO> mtu 16 qdisc noop state DOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 
    can state STOPPED restart-ms 0 
    bitrate 0 sample-point 0.000 
    tq 0 prop-seg 0 phase-seg1 0 phase-seg2 0 sjw 0
    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  
As I understood, can0 interface is still unconfigured, so programs cant use it. What shall I do to make it active?

Best Regards
Alex

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Tue 15. Nov 2016, 12:40
by M.Maidhof
Hi,

now you have to configure the device with "ip link set", see SocketCAN documentation:

https://www.kernel.org/doc/Documentatio ... ng/can.txt

or see info in our Linux driver manual on page 33.

regards

Michael

Re: PCAN-USB: build as netdev for kernel 3.13

Posted: Wed 16. Nov 2016, 08:12
by alexanderg
Michael, Thank you a lot!
Alex