* kvaser leaf and SocketCAN
@ 2015-04-22 7:31 max
2015-04-22 8:03 ` Marc Kleine-Budde
0 siblings, 1 reply; 17+ messages in thread
From: max @ 2015-04-22 7:31 UTC (permalink / raw)
To: linux-can
Hello,
I'm trying to connect to a Kvaser Leaf Light V2 (product_id=15) adapter on
linux from python3.4, and for that purpose I've planned to use SocketCAN.
I have downloaded and compiled the kvaser drivers v.5.9, my kernel is a
3.13.0-49-generic, and according to the information I've fund so far, the
system requirements should all be met.
And in fact, when I connect the adapter, the leaf kernel module is
correctly loaded (I see it in lsmod) and the /usr/sbin/leaf.sh is started
(I desume this from the fact that if I try to start it manually it tells me
it has already been started), and also the /dev/leaf0 device is created.
So far so good. But what's next? What I have understood is that at this
point there should be the kvaser_usb module that comes into play for
mapping the device to a network interface that can be brought up and used
by SocketCAN.
But the kvaser_usb module is not loaded automatically, and if I modprobe it
manually, nothing seems to happen.
Here is what goes on in the kernel log when connecting the adapter:
[46464.671385] usb 3-2: new high-speed USB device number 4 using xhci_hcd
[46464.689616] usb 3-2: New USB device found, idVendor=0bfd, idProduct=0120
[46464.689627] usb 3-2: New USB device strings: Mfr=0, Product=2,
SerialNumber=0
[46464.689633] usb 3-2: Product: Kvaser Leaf Light v2
[46467.738639] usbcore: registered new interface driver leaf
And this when I modprobe the kvaser_usb module:
[46545.271520] usbcore: registered new interface driver kvaser_usb
If I invert the order of the two operations, it is exactly the same. I've
also tryed with and without an actual can device connected to the other end
of the adapter, but this doesn't change anything either.
So, it looks I am still missing something... Can anyone tell me what
further steps are necessary to finally get a can0 interface to show up?
Thank's a lot for any hint pointing me to the right direction...
Max
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-22 7:31 kvaser leaf and SocketCAN max
@ 2015-04-22 8:03 ` Marc Kleine-Budde
2015-04-29 2:01 ` Leo Stan
0 siblings, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2015-04-22 8:03 UTC (permalink / raw)
To: max, linux-can
[-- Attachment #1: Type: text/plain, Size: 2825 bytes --]
On 04/22/2015 09:31 AM, max wrote:
> I'm trying to connect to a Kvaser Leaf Light V2 (product_id=15) adapter on
> linux from python3.4, and for that purpose I've planned to use SocketCAN.
>
> I have downloaded and compiled the kvaser drivers v.5.9, my kernel is a
> 3.13.0-49-generic, and according to the information I've fund so far, the
> system requirements should all be met.
Where do you download the driver from? I suggest to use a recent
mainline kernel. Support for the Kvaser Leaf v2 was added in v3.16 and a
_lot_ of bugfixes were added in later versions. Switching to a recent
ubuntu kernel (v3.19) is probably a good idea.
> And in fact, when I connect the adapter, the leaf kernel module is
> correctly loaded (I see it in lsmod) and the /usr/sbin/leaf.sh is started
> (I desume this from the fact that if I try to start it manually it tells me
> it has already been started), and also the /dev/leaf0 device is created.
A /dev/leaf0 is not created by the mainline driver...
> So far so good. But what's next? What I have understood is that at this
> point there should be the kvaser_usb module that comes into play for
> mapping the device to a network interface that can be brought up and used
> by SocketCAN.
>
> But the kvaser_usb module is not loaded automatically, and if I modprobe it
> manually, nothing seems to happen.
>
> Here is what goes on in the kernel log when connecting the adapter:
>
> [46464.671385] usb 3-2: new high-speed USB device number 4 using xhci_hcd
> [46464.689616] usb 3-2: New USB device found, idVendor=0bfd, idProduct=0120
> [46464.689627] usb 3-2: New USB device strings: Mfr=0, Product=2,
> SerialNumber=0
> [46464.689633] usb 3-2: Product: Kvaser Leaf Light v2
> [46467.738639] usbcore: registered new interface driver leaf
>
> And this when I modprobe the kvaser_usb module:
>
> [46545.271520] usbcore: registered new interface driver kvaser_usb
>
> If I invert the order of the two operations, it is exactly the same. I've
> also tryed with and without an actual can device connected to the other end
> of the adapter, but this doesn't change anything either.
>
> So, it looks I am still missing something... Can anyone tell me what
> further steps are necessary to finally get a can0 interface to show up?
>
> Thank's a lot for any hint pointing me to the right direction...
Use a recent mainline kernel, then everything should work out of the
box, without any external drivers and manual module loading.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-22 8:03 ` Marc Kleine-Budde
@ 2015-04-29 2:01 ` Leo Stan
2015-04-29 3:50 ` Austin Schuh
0 siblings, 1 reply; 17+ messages in thread
From: Leo Stan @ 2015-04-29 2:01 UTC (permalink / raw)
To: linux-can
Marc Kleine-Budde <mkl <at> pengutronix.de> writes:
>
> On 04/22/2015 09:31 AM, max wrote:
> > I'm trying to connect to a Kvaser Leaf Light V2 (product_id=15) adapter
on
> > linux from python3.4, and for that purpose I've planned to use
SocketCAN.
> >
> > I have downloaded and compiled the kvaser drivers v.5.9, my kernel is a
> > 3.13.0-49-generic, and according to the information I've fund so far,
the
> > system requirements should all be met.
>
> Where do you download the driver from? I suggest to use a recent
> mainline kernel. Support for the Kvaser Leaf v2 was added in v3.16 and a
> _lot_ of bugfixes were added in later versions. Switching to a recent
> ubuntu kernel (v3.19) is probably a good idea.
>
> > And in fact, when I connect the adapter, the leaf kernel module is
> > correctly loaded (I see it in lsmod) and the /usr/sbin/leaf.sh is
started
> > (I desume this from the fact that if I try to start it manually it
tells me
> > it has already been started), and also the /dev/leaf0 device is
created.
>
> A /dev/leaf0 is not created by the mainline driver...
>
> > So far so good. But what's next? What I have understood is that at this
> > point there should be the kvaser_usb module that comes into play for
> > mapping the device to a network interface that can be brought up and
used
> > by SocketCAN.
> >
> > But the kvaser_usb module is not loaded automatically, and if I
modprobe it
> > manually, nothing seems to happen.
> >
> > Here is what goes on in the kernel log when connecting the adapter:
> >
> > [46464.671385] usb 3-2: new high-speed USB device number 4 using
xhci_hcd
> > [46464.689616] usb 3-2: New USB device found, idVendor=0bfd,
idProduct=0120
> > [46464.689627] usb 3-2: New USB device strings: Mfr=0, Product=2,
> > SerialNumber=0
> > [46464.689633] usb 3-2: Product: Kvaser Leaf Light v2
> > [46467.738639] usbcore: registered new interface driver leaf
> >
> > And this when I modprobe the kvaser_usb module:
> >
> > [46545.271520] usbcore: registered new interface driver kvaser_usb
> >
> > If I invert the order of the two operations, it is exactly the same.
I've
> > also tryed with and without an actual can device connected to the other
end
> > of the adapter, but this doesn't change anything either.
> >
> > So, it looks I am still missing something... Can anyone tell me what
> > further steps are necessary to finally get a can0 interface to show up?
> >
> > Thank's a lot for any hint pointing me to the right direction...
>
> Use a recent mainline kernel, then everything should work out of the
> box, without any external drivers and manual module loading.
>
> Marc
Hi Marc and Max,
I am also trying to use this device on Ubuntu 14.04 with Linux kernel
3.19.0-031900-generic.
When I connect the device I have the kernel log as follow
[ 3506.638843] usb 1-3: USB disconnect, device number 6
[ 3508.818400] usb 1-3: new high-speed USB device number 7 using xhci_hcd
[ 3508.949596] usb 1-3: New USB device found, idVendor=0bfd, idProduct=0120
[ 3508.949603] usb 1-3: New USB device strings: Mfr=0, Product=2,
SerialNumber=0
[ 3508.949607] usb 1-3: Product: Kvaser Leaf Light HS
I have installed the drivers from Kvaser for linux therefore I have the
modules :
kvaser_usb 22385 0
can_dev 21659 1 kvaser_usb
However nothing appears in /dev folder
I tried the SocketCan example code from this wiki page :
http://en.wikipedia.org/wiki/SocketCAN
But I get this error :
vcan0 at index -571419056
Error in socket bind: No such device
Thanks in advance for any help.
Leo
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-29 2:01 ` Leo Stan
@ 2015-04-29 3:50 ` Austin Schuh
2015-04-29 4:39 ` Leo Stan
0 siblings, 1 reply; 17+ messages in thread
From: Austin Schuh @ 2015-04-29 3:50 UTC (permalink / raw)
To: Leo Stan; +Cc: linux-can
On Tue, Apr 28, 2015 at 7:01 PM, Leo Stan <leo.stanislas@qut.edu.au> wrote:
> When I connect the device I have the kernel log as follow
>
> [ 3506.638843] usb 1-3: USB disconnect, device number 6
> [ 3508.818400] usb 1-3: new high-speed USB device number 7 using xhci_hcd
> [ 3508.949596] usb 1-3: New USB device found, idVendor=0bfd, idProduct=0120
> [ 3508.949603] usb 1-3: New USB device strings: Mfr=0, Product=2,
> SerialNumber=0
> [ 3508.949607] usb 1-3: Product: Kvaser Leaf Light HS
>
> I have installed the drivers from Kvaser for linux therefore I have the
> modules :
>
> kvaser_usb 22385 0
> can_dev 21659 1 kvaser_usb
>
> However nothing appears in /dev folder
>
> I tried the SocketCan example code from this wiki page :
>
> http://en.wikipedia.org/wiki/SocketCAN
>
> But I get this error :
>
> vcan0 at index -571419056
> Error in socket bind: No such device
You won't see anything in /dev/ if socketcan is working correctly.
Try ifconfig -a to see the interface. From one of my machines (with a
SJA1000 from Peak):
$ ifconfig -a
can0 Link encap:UNSPEC HWaddr
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING 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)
Interrupt:18
Austin
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: kvaser leaf and SocketCAN
2015-04-29 3:50 ` Austin Schuh
@ 2015-04-29 4:39 ` Leo Stan
2015-04-29 5:20 ` Marc Kleine-Budde
0 siblings, 1 reply; 17+ messages in thread
From: Leo Stan @ 2015-04-29 4:39 UTC (permalink / raw)
To: linux-can
Austin Schuh <austin <at> peloton-tech.com> writes:
>
> $ ifconfig -a
> can0 Link encap:UNSPEC HWaddr
> 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
> UP RUNNING 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)
> Interrupt:18
>
> Austin
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo <at> vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
Hi Austin, thanks for your reply.
My ifconfig -a returns :
eth0 Link encap:Ethernet HWaddr 44:8a:5b:6d:50:8d
inet addr:131.181.70.9 Bcast:131.181.70.255 Mask:255.255.255.0
inet6 addr: fe80::468a:5bff:fe6d:508d/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3869 errors:0 dropped:0 overruns:0 frame:0
TX packets:1783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1268663 (1.2 MB) TX bytes:481256 (481.2 KB)
Interrupt:19
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:228 errors:0 dropped:0 overruns:0 frame:0
TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:37579 (37.5 KB) TX bytes:37579 (37.5 KB)
wlan0 Link encap:Ethernet HWaddr e8:2a:ea:de:3b:ae
UP BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
So I don't think it detected the Leaf...
Now that I check my /dev/ folder there is actually leaf0 in it. Maybe
installing the drivers from Kvaser prevents me from using SocketCan?
Also I have all of these modules running that a related to the leaf :
can_raw 17159 0
can 45043 1 can_raw
kvaser_usb 22385 0
can_dev 21659 1 kvaser_usb
leaf 43136 1
Thank you for your help
Leo
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: kvaser leaf and SocketCAN
2015-04-29 4:39 ` Leo Stan
@ 2015-04-29 5:20 ` Marc Kleine-Budde
2015-04-29 6:15 ` Leo Stan
2015-04-29 10:45 ` Ahmed S. Darwish
0 siblings, 2 replies; 17+ messages in thread
From: Marc Kleine-Budde @ 2015-04-29 5:20 UTC (permalink / raw)
To: Leo Stan, linux-can
[-- Attachment #1: Type: text/plain, Size: 1986 bytes --]
On 04/29/2015 06:39 AM, Leo Stan wrote:
> Hi Austin, thanks for your reply.
>
> My ifconfig -a returns :
>
> eth0 Link encap:Ethernet HWaddr 44:8a:5b:6d:50:8d
> inet addr:131.181.70.9 Bcast:131.181.70.255 Mask:255.255.255.0
> inet6 addr: fe80::468a:5bff:fe6d:508d/64 Scope:Link
> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> RX packets:3869 errors:0 dropped:0 overruns:0 frame:0
> TX packets:1783 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:1000
> RX bytes:1268663 (1.2 MB) TX bytes:481256 (481.2 KB)
> Interrupt:19
>
> lo Link encap:Local Loopback
> inet addr:127.0.0.1 Mask:255.0.0.0
> inet6 addr: ::1/128 Scope:Host
> UP LOOPBACK RUNNING MTU:65536 Metric:1
> RX packets:228 errors:0 dropped:0 overruns:0 frame:0
> TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
> collisions:0 txqueuelen:0
> RX bytes:37579 (37.5 KB) TX bytes:37579 (37.5 KB)
>
> wlan0 Link encap:Ethernet HWaddr e8:2a:ea:de:3b:ae
> UP BROADCAST MULTICAST MTU:1500 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:1000
> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
>
> So I don't think it detected the Leaf...
>
> Now that I check my /dev/ folder there is actually leaf0 in it. Maybe
> installing the drivers from Kvaser prevents me from using SocketCan?
This can be the problem. Please try with the mainline drivers only.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-29 5:20 ` Marc Kleine-Budde
@ 2015-04-29 6:15 ` Leo Stan
2015-04-29 6:33 ` Alexander Stein
2015-04-29 6:34 ` Marc Kleine-Budde
2015-04-29 10:45 ` Ahmed S. Darwish
1 sibling, 2 replies; 17+ messages in thread
From: Leo Stan @ 2015-04-29 6:15 UTC (permalink / raw)
To: linux-can
Marc Kleine-Budde <mkl <at> pengutronix.de> writes:
>
> On 04/29/2015 06:39 AM, Leo Stan wrote:
> > Hi Austin, thanks for your reply.
> >
> > My ifconfig -a returns :
> >
> > eth0 Link encap:Ethernet HWaddr 44:8a:5b:6d:50:8d
> > inet addr:131.181.70.9 Bcast:131.181.70.255
Mask:255.255.255.0
> > inet6 addr: fe80::468a:5bff:fe6d:508d/64 Scope:Link
> > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> > RX packets:3869 errors:0 dropped:0 overruns:0 frame:0
> > TX packets:1783 errors:0 dropped:0 overruns:0 carrier:0
> > collisions:0 txqueuelen:1000
> > RX bytes:1268663 (1.2 MB) TX bytes:481256 (481.2 KB)
> > Interrupt:19
> >
> > lo Link encap:Local Loopback
> > inet addr:127.0.0.1 Mask:255.0.0.0
> > inet6 addr: ::1/128 Scope:Host
> > UP LOOPBACK RUNNING MTU:65536 Metric:1
> > RX packets:228 errors:0 dropped:0 overruns:0 frame:0
> > TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
> > collisions:0 txqueuelen:0
> > RX bytes:37579 (37.5 KB) TX bytes:37579 (37.5 KB)
> >
> > wlan0 Link encap:Ethernet HWaddr e8:2a:ea:de:3b:ae
> > UP BROADCAST MULTICAST MTU:1500 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:1000
> > RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
> >
> > So I don't think it detected the Leaf...
> >
> > Now that I check my /dev/ folder there is actually leaf0 in it. Maybe
> > installing the drivers from Kvaser prevents me from using SocketCan?
>
> This can be the problem. Please try with the mainline drivers only.
>
> Marc
>
Hello Marc,
I uninstalled the driver and now :
- I don't have the leaf in /dev/ when I plug it, which is a good thing
- I have those modules running :
can_raw 17159 0
can 45043 1 can_raw
kvaser_usb 22385 0
can_dev 21659 1 kvaser_usb
- ifconfig -a shows the CAN :
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)
- My kernel log shows :
usb 1-3: new high-speed USB device number 4 using xhci_hcd
[ 1393.767114] usb 1-3: New USB device found, idVendor=0bfd, idProduct=0120
[ 1393.767124] usb 1-3: New USB device strings: Mfr=0, Product=2,
SerialNumber=0
[ 1393.767128] usb 1-3: Product: Kvaser Leaf Light HS
[ 1393.815801] CAN device driver interface
[ 1393.857896] usbcore: registered new interface driver kvaser_usb
- When I try to run the example from http://en.wikipedia.org/wiki/SocketCAN I get this error :
vcan0 at index 1866752400
Error in socket bind: No such device
Thanks a lot for helping me.
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: kvaser leaf and SocketCAN
2015-04-29 6:15 ` Leo Stan
@ 2015-04-29 6:33 ` Alexander Stein
2015-04-29 6:34 ` Marc Kleine-Budde
1 sibling, 0 replies; 17+ messages in thread
From: Alexander Stein @ 2015-04-29 6:33 UTC (permalink / raw)
To: Leo Stan; +Cc: linux-can
Hi Leo,
On Wednesday 29 April 2015 06:15:53, Leo Stan wrote:
> - ifconfig -a shows the CAN :
>
> can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-
^^^^
Compare this with...
> 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)
>
> - My kernel log shows :
>
> usb 1-3: new high-speed USB device number 4 using xhci_hcd
> [ 1393.767114] usb 1-3: New USB device found, idVendor=0bfd, idProduct=0120
> [ 1393.767124] usb 1-3: New USB device strings: Mfr=0, Product=2,
> SerialNumber=0
> [ 1393.767128] usb 1-3: Product: Kvaser Leaf Light HS
> [ 1393.815801] CAN device driver interface
> [ 1393.857896] usbcore: registered new interface driver kvaser_usb
>
> - When I try to run the example from http://en.wikipedia.org/wiki/SocketCAN I get this error :
>
> vcan0 at index 1866752400
^^^^^
...this. Notice the difference?
You also might want to use https://github.com/linux-can/can-utils/
HTH
Alexander
--
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
Am Windrad 2
08468 Heinsdorfergrund
Tel.: 03765 38600-1156
Fax: 03765 38600-4100
Email: alexander.stein@systec-electronic.com
Website: www.systec-electronic.com
Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Chemnitz, HRB 28082
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-29 6:15 ` Leo Stan
2015-04-29 6:33 ` Alexander Stein
@ 2015-04-29 6:34 ` Marc Kleine-Budde
1 sibling, 0 replies; 17+ messages in thread
From: Marc Kleine-Budde @ 2015-04-29 6:34 UTC (permalink / raw)
To: Leo Stan, linux-can
[-- Attachment #1: Type: text/plain, Size: 1785 bytes --]
On 04/29/2015 08:15 AM, Leo Stan wrote:
> I uninstalled the driver and now :
>
> - I don't have the leaf in /dev/ when I plug it, which is a good thing
> - I have those modules running :
>
> can_raw 17159 0
> can 45043 1 can_raw
> kvaser_usb 22385 0
> can_dev 21659 1 kvaser_usb
>
> - ifconfig -a shows the CAN :
>
> 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)
\o/
> - My kernel log shows :
>
> usb 1-3: new high-speed USB device number 4 using xhci_hcd
> [ 1393.767114] usb 1-3: New USB device found, idVendor=0bfd, idProduct=0120
> [ 1393.767124] usb 1-3: New USB device strings: Mfr=0, Product=2,
> SerialNumber=0
> [ 1393.767128] usb 1-3: Product: Kvaser Leaf Light HS
> [ 1393.815801] CAN device driver interface
> [ 1393.857896] usbcore: registered new interface driver kvaser_usb
>
> - When I try to run the example from http://en.wikipedia.org/wiki/SocketCAN I get this error :
>
> vcan0 at index 1866752400
^^^^^
> Error in socket bind: No such device
You're using "can0" - the example is for virtual CAN device "vcan0".
Please change the interface in the Code.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-29 5:20 ` Marc Kleine-Budde
2015-04-29 6:15 ` Leo Stan
@ 2015-04-29 10:45 ` Ahmed S. Darwish
2015-04-30 3:11 ` Leo Stan
1 sibling, 1 reply; 17+ messages in thread
From: Ahmed S. Darwish @ 2015-04-29 10:45 UTC (permalink / raw)
To: Marc Kleine-Budde; +Cc: Leo Stan, linux-can
On Wed, Apr 29, 2015 at 07:20:03AM +0200, Marc Kleine-Budde wrote:
> On 04/29/2015 06:39 AM, Leo Stan wrote:
> > Hi Austin, thanks for your reply.
> >
> > My ifconfig -a returns :
> >
> > eth0 Link encap:Ethernet HWaddr 44:8a:5b:6d:50:8d
> > inet addr:131.181.70.9 Bcast:131.181.70.255 Mask:255.255.255.0
> > inet6 addr: fe80::468a:5bff:fe6d:508d/64 Scope:Link
> > UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
> > RX packets:3869 errors:0 dropped:0 overruns:0 frame:0
> > TX packets:1783 errors:0 dropped:0 overruns:0 carrier:0
> > collisions:0 txqueuelen:1000
> > RX bytes:1268663 (1.2 MB) TX bytes:481256 (481.2 KB)
> > Interrupt:19
> >
> > lo Link encap:Local Loopback
> > inet addr:127.0.0.1 Mask:255.0.0.0
> > inet6 addr: ::1/128 Scope:Host
> > UP LOOPBACK RUNNING MTU:65536 Metric:1
> > RX packets:228 errors:0 dropped:0 overruns:0 frame:0
> > TX packets:228 errors:0 dropped:0 overruns:0 carrier:0
> > collisions:0 txqueuelen:0
> > RX bytes:37579 (37.5 KB) TX bytes:37579 (37.5 KB)
> >
> > wlan0 Link encap:Ethernet HWaddr e8:2a:ea:de:3b:ae
> > UP BROADCAST MULTICAST MTU:1500 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:1000
> > RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
> >
> > So I don't think it detected the Leaf...
> >
> > Now that I check my /dev/ folder there is actually leaf0 in it. Maybe
> > installing the drivers from Kvaser prevents me from using SocketCan?
Yes, per their release notes, the Kvaser out-of-tree driver scripts
blacklists the in-tree SocketCAN driver to prevent it from auto-loading:
http://www.kvaser.com/software/7330130980754/relnotes/relnotes_linuxcan.txt
>
> This can be the problem. Please try with the mainline drivers only.
>
Exactly.
Regards,
Darwish
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-29 10:45 ` Ahmed S. Darwish
@ 2015-04-30 3:11 ` Leo Stan
2015-04-30 6:04 ` Marc Kleine-Budde
2015-04-30 6:14 ` Leo Stan
0 siblings, 2 replies; 17+ messages in thread
From: Leo Stan @ 2015-04-30 3:11 UTC (permalink / raw)
To: linux-can
Thanks a lot everyone for your help, it finally works!
The example code output :
can0 at index 4
Wrote -1 bytes
I wish you all the best,
Leo
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-30 3:11 ` Leo Stan
@ 2015-04-30 6:04 ` Marc Kleine-Budde
2015-04-30 6:14 ` Leo Stan
1 sibling, 0 replies; 17+ messages in thread
From: Marc Kleine-Budde @ 2015-04-30 6:04 UTC (permalink / raw)
To: Leo Stan, linux-can
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
On 04/30/2015 05:11 AM, Leo Stan wrote:
>
> Thanks a lot everyone for your help, it finally works!
>
> The example code output :
>
> can0 at index 4
> Wrote -1 bytes
^^
This doens't look that good. When write() returns -1, something went
wrong. Have a look at "errno".
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: kvaser leaf and SocketCAN
2015-04-30 3:11 ` Leo Stan
2015-04-30 6:04 ` Marc Kleine-Budde
@ 2015-04-30 6:14 ` Leo Stan
2015-04-30 6:25 ` Leo Stan
2015-04-30 6:48 ` Marc Kleine-Budde
1 sibling, 2 replies; 17+ messages in thread
From: Leo Stan @ 2015-04-30 6:14 UTC (permalink / raw)
To: linux-can
Actually I spoke too soon...
When I try this simple code from the documentation :
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <net/if.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <linux/can.h>
#include <linux/can/raw.h>
int main(void)
{
int s;
int nbytes;
struct sockaddr_can addr;
struct can_frame frame;
struct ifreq ifr;
char *ifname = "can0";
if((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
perror("Error while opening socket");
return -1;
}
strcpy(ifr.ifr_name, ifname);
ioctl(s, SIOCGIFINDEX, &ifr);
addr.can_family = AF_CAN;
addr.can_ifindex = ifr.ifr_ifindex;
printf("%s at index %d\n", ifname, ifr.ifr_ifindex);
if(bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("Error in socket bind");
return -2;
}
// Reading the CAN port
nbytes=read(s,&frame,sizeof(struct can_frame));
if (nbytes < 0) {
perror("can raw socket read");
return 1;
}
/* paranoid check ... */
if (nbytes < sizeof(struct can_frame)) {
fprintf(stderr, "read: incomplete CAN frame\n");
return 1;
}
printf("dlc = %d, data = %s, %d bytes read\n",
frame.can_dlc,frame.data,nbytes);
close(s);
return 0;
}
I get this flag :
can0 at index 3
can raw socket read: Network is down
Which means that nothing has been read from the CAN I guess, however I'm
sure that data comes from it because I can see it using CANking software on
Windows.
When I run "ifconfig -a" RX and TX are also empty:
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)
Here are the settings of my BUS on Canking :
No init access
Speed : 500000 Bit/s
Bit timing : Q=8, S1=5,S2=3,Sampling point= 62.5%, SJW=1
DLC = 8
Any help would be really appreciated
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: kvaser leaf and SocketCAN
2015-04-30 6:14 ` Leo Stan
@ 2015-04-30 6:25 ` Leo Stan
2015-04-30 6:48 ` Marc Kleine-Budde
1 sibling, 0 replies; 17+ messages in thread
From: Leo Stan @ 2015-04-30 6:25 UTC (permalink / raw)
To: linux-can
Thanks for your help Marc.
errno = 100 for both tests, when I try to write and when I try to read.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: kvaser leaf and SocketCAN
2015-04-30 6:14 ` Leo Stan
2015-04-30 6:25 ` Leo Stan
@ 2015-04-30 6:48 ` Marc Kleine-Budde
2015-04-30 7:27 ` Oliver Hartkopp
1 sibling, 1 reply; 17+ messages in thread
From: Marc Kleine-Budde @ 2015-04-30 6:48 UTC (permalink / raw)
To: Leo Stan, linux-can
[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]
On 04/30/2015 08:14 AM, Leo Stan wrote:
>
> Actually I spoke too soon...
>
> When I try this simple code from the documentation :
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <string.h>
>
> #include <net/if.h>
> #include <sys/types.h>
> #include <sys/socket.h>
> #include <sys/ioctl.h>
>
> #include <linux/can.h>
> #include <linux/can/raw.h>
>
> int main(void)
> {
> int s;
> int nbytes;
> struct sockaddr_can addr;
> struct can_frame frame;
> struct ifreq ifr;
>
> char *ifname = "can0";
>
> if((s = socket(PF_CAN, SOCK_RAW, CAN_RAW)) < 0) {
> perror("Error while opening socket");
> return -1;
> }
>
> strcpy(ifr.ifr_name, ifname);
> ioctl(s, SIOCGIFINDEX, &ifr);
>
> addr.can_family = AF_CAN;
> addr.can_ifindex = ifr.ifr_ifindex;
>
> printf("%s at index %d\n", ifname, ifr.ifr_ifindex);
>
> if(bind(s, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
> perror("Error in socket bind");
> return -2;
> }
>
> // Reading the CAN port
>
>
> nbytes=read(s,&frame,sizeof(struct can_frame));
>
> if (nbytes < 0) {
> perror("can raw socket read");
> return 1;
> }
>
> /* paranoid check ... */
> if (nbytes < sizeof(struct can_frame)) {
> fprintf(stderr, "read: incomplete CAN frame\n");
> return 1;
> }
>
> printf("dlc = %d, data = %s, %d bytes read\n",
> frame.can_dlc,frame.data,nbytes);
>
> close(s);
>
> return 0;
> }
>
> I get this flag :
>
> can0 at index 3
> can raw socket read: Network is down
^^^^^^^^^^^^^^^
You have to configure your CAN network device first, then bring it into
an operational state, this means the network is "up".
ip link set can0 type can bitrate 500000
ip link set can0 up
See section "6.5.1 Netlink interface to set/get devices properties"
http://lxr.free-electrons.com/source/Documentation/networking/can.txt#L990
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2015-05-04 1:52 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-22 7:31 kvaser leaf and SocketCAN max
2015-04-22 8:03 ` Marc Kleine-Budde
2015-04-29 2:01 ` Leo Stan
2015-04-29 3:50 ` Austin Schuh
2015-04-29 4:39 ` Leo Stan
2015-04-29 5:20 ` Marc Kleine-Budde
2015-04-29 6:15 ` Leo Stan
2015-04-29 6:33 ` Alexander Stein
2015-04-29 6:34 ` Marc Kleine-Budde
2015-04-29 10:45 ` Ahmed S. Darwish
2015-04-30 3:11 ` Leo Stan
2015-04-30 6:04 ` Marc Kleine-Budde
2015-04-30 6:14 ` Leo Stan
2015-04-30 6:25 ` Leo Stan
2015-04-30 6:48 ` Marc Kleine-Budde
2015-04-30 7:27 ` Oliver Hartkopp
2015-05-04 1:52 ` Leo Stan
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.