PCAN-USB: build as netdev for kernel 3.13

This forum covers PCAN-Linux and Linux development issues concerning our products
Post Reply
alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

PCAN-USB: build as netdev for kernel 3.13

Post by alexanderg » Mon 14. Nov 2016, 09:38

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

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

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

Post by S.Grosjean » Mon 14. Nov 2016, 14:23

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
— Stéphane

alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

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

Post by alexanderg » Mon 14. Nov 2016, 14:51

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

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

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

Post by S.Grosjean » Mon 14. Nov 2016, 15:04

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
— Stéphane

alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

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

Post by alexanderg » Mon 14. Nov 2016, 15:11

Hi,

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

Alex.

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

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

Post by S.Grosjean » Mon 14. Nov 2016, 16:42

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
— Stéphane

alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

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

Post by alexanderg » Mon 14. Nov 2016, 16:54

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

alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

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

Post by alexanderg » Tue 15. Nov 2016, 10:23

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
Last edited by M.Gerber on Wed 16. Nov 2016, 10:02, edited 1 time in total.
Reason: Inserted [code] tags for better readability.

M.Maidhof
Support
Support
Posts: 1753
Joined: Wed 22. Sep 2010, 14:00

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

Post by M.Maidhof » Tue 15. Nov 2016, 12:40

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

alexanderg
Posts: 6
Joined: Mon 14. Nov 2016, 08:52

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

Post by alexanderg » Wed 16. Nov 2016, 08:12

Michael, Thank you a lot!
Alex

Post Reply