Re: Getting manufacturer/product name for CAN interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Wolfgang,

thanks for your answer.

> The SysFS file "interface" is specific to the USB layer and is printed
> here:
>
>
https://elixir.bootlin.com/linux/latest/source/drivers/usb/core/sysfs.c#L992

Ah, thanks for the hint.

> For USB, the string is optional and such a file does not exists for
> the PCI layer.


Ok, that explains it. When I did my tests one year ago, I only used USB
interfaces as I had no computer with PCI slots running Linux. Now I was
very surprised my PCAN PCIex card didn't show up - "damn, wasn't that
working already?"

> It shows the USB "iInterface" string, if present.
> What does "lsusb -vv" list for that device?

I don't have the hardware at hand now, I'll test that during the weekend
with my available adapters.

Thanks also for your other links, I'll look them up too.

Best regards,
André

Am 20.03.19 um 22:38 schrieb Wolfgang Grandegger:
Hello Andre,

Am 20.03.19 um 20:59 schrieb André Hartmann:
Hi all,

I know it is a long time, but I need to come back to this topic.

In principle, /sys/class/net/canX/device/interface gives me some
information to the connected device, e.g.:

LANG=C cat /sys/class/net/can0/device/interface
PCAN-USB Pro FD CAN

LANG=C cat /sys/class/net/can2/device/interface
USB-CANmodul2

The SysFS file "interface" is specific to the USB layer and is printed
here:

https://elixir.bootlin.com/linux/latest/source/drivers/usb/core/sysfs.c#L992

It shows the USB "iInterface" string, if present.
What does "lsusb -vv" list for that device?

Interestingly, for PCAN-USB and PCAN-PCIexpress (2 channel), there is no
such information; the file interface does not even exist.

For USB, the string is optional and such a file does not exists for the PCI
layer.

I'm on Kernel 4.15.0 here.

I don't have access to other CAN adapters, so I don't know the general
status, but  would hope that such important information is accessible
from userspace. I guess it's the vendors responsibility to add such
information?

As mentioned above, even for USB, such information is optional. The
vendor of the USB device do not need to provide it. There is no common
API to derive the name string of a device. It's layer-specific. For
PCI, you usually interpret the Device and Vendor ID. This also works
for USB. Have a look to the output of

   $ lspci -vv
   $ lsusb -vv

For CAN, we provide the name of the basic CAN controller hardware by
the "struct can_bittiming_const":

   https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/can/netlink.h#L47

which you can list with:

   $ ip --details link show can0

Wolfgang.

Am 19.07.17 um 19:42 schrieb aha_1980@xxxxxx:
Hi Marc,

Am Dienstag 18. Juli 2017 schrieb Marc Kleine-Budde:
On 07/17/2017 09:36 PM, André Hartmann wrote:
thanks for your hints! I've investigated a bit (with PEAK and SYSTEC
adapters) and I'm partly satisfied.

Wolfgangs tip with ip -d gives me indeed the driver associated to a
CAN interface. And in /sys/class/net/can0/subsystem/can0/device/
interface I found the device string, thanks Marcel. (Full logs are
appended).

However, the most important infos are still only visible in dmesg.
It's the drivers output which CAN channel is associated with each
hardware interface, e.g.:

peak_usb 2-1.4:1.0: PEAK-System PCAN-USB Pro [...] (2 channels)
peak_usb 2-1.4:1.0 can0: attached to PCAN-USB Pro channel 0 (device 1)
peak_usb 2-1.4:1.0 can1: attached to PCAN-USB Pro channel 1 (device 0)

So if there is no way to get these infos from userspace now, I think it
would be a good addition to have this possibility. Especially if there
is more than one CAN adapter connected.

Does the udev property dev_id help? See
http://permalink.gmane.org/gmane.linux.can/5227 for more information.

That looks indeed interesting. My Google-foo tells me the patch was
included in a pull request, so it should be merged to mainline Kernel.

Let's see what I can achive.

Thanks, Andre

regards,
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  ; |










[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux