I have Ubuntu server (22.04.2 LTS) with multiple PCAN devices connected,
CAN driver info:
$ modinfo pcanfilename: /lib/modules/6.5.0-26-generic/misc/pcan.kolicense: GPLversion: Release_20240116_ndescription: Driver for PEAK-System CAN interfacesauthor: klaus.hitschler@gmx.deauthor: s.grosjean@peak-system.comsrcversion: 9B91AA025C2BA6422309BBBalias: usb:v0C72p0014d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v0C72p0013d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v0C72p0011d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v0C72p0012d*dc*dsc*dp*ic*isc*ip*in*alias: usb:v0C72p000Dd*dc*dsc*dp*ic*isc*ip*in*alias: usb:v0C72p000Cd*dc*dsc*dp*ic*isc*ip*in*alias: pci:v0000001Cd0000001Asv*sd*bc*sc*i*alias: pci:v0000001Cd00000019sv*sd*bc*sc*i*alias: pci:v0000001Cd00000018sv*sd*bc*sc*i*alias: pci:v0000001Cd00000017sv*sd*bc*sc*i*alias: pci:v0000001Cd00000016sv*sd*bc*sc*i*alias: pci:v0000001Cd00000014sv*sd*bc*sc*i*alias: pci:v0000001Cd00000013sv*sd*bc*sc*i*alias: pci:v0000001Cd00000010sv*sd*bc*sc*i*alias: pci:v0000001Cd0000000Asv*sd*bc*sc*i*alias: pci:v0000001Cd00000002sv*sd*bc*sc*i*alias: pci:v0000001Cd00000009sv*sd*bc*sc*i*alias: pci:v0000001Cd00000008sv*sd*bc*sc*i*alias: pci:v0000001Cd00000007sv*sd*bc*sc*i*alias: pci:v0000001Cd00000006sv*sd*bc*sc*i*alias: pci:v0000001Cd00000005sv*sd*bc*sc*i*alias: pci:v0000001Cd00000004sv*sd*bc*sc*i*alias: pci:v0000001Cd00000003sv*sd*bc*sc*i*alias: pci:v0000001Cd00000001sv*sd*bc*sc*i*depends: i2c-algo-bitretpoline: Yname: pcanvermagic: 6.5.0-26-generic SMP preempt mod_unload modversions parm: fdusemsi: 0=INTA; 1=MSI (not shared); 2=MSI (shared) (def=0) (byte)parm: fdirqcl: PCIe FD IRQ Count Limit (default=16) (uint)parm: fdirqtl: PCIe FD IRQ Time Limit (default=10) (uint)parm: usemsi: 0=INTA; 1=MSI (not shared); 2=MSI (shared) (def=0) (byte)parm: fast_fwd: set fast forward option in USB device (def=0) (ushort)parm: irqmaxloop: max loops in ISR per CAN (0=default def=6) (uint)parm: irqmaxrmsg: max msgs read per Rx IRQ (0=default def=8) (uint)parm: type:type of PCAN interface (isa, sp, epp) (array of charp)parm: io:io-port address for either PCAN-ISA, PC/104 or Dongle (array of ulong)parm: irq:interrupt number for either PCAN-ISA, PC/104 or Dongle (array of byte)parm: btr0btr1:initial bitrate (BTR0BTR1 format) for all channels (ushort)parm: bitrate:initial nominal bitrate for all channels (charp)parm: dbitrate:initial data bitrate for all CAN-FD channels (charp)parm: rxqsize: size of the Rx FIFO of a channel (def=2000) (ushort)parm: rxqprealloc:allocate Rx FIFO once at probe time (byte)parm: txqsize: size of the Tx FIFO of a channel (def=500) (ushort)parm: txqprealloc:allocate Tx FIFO once at probe time (byte)parm: dmamask: [24..64] (def=64) (ushort)parm: deftsmode: default ts mode (ushort)parm: defblperiod: default bus load msg period (def=500 ms.) (ushort)parm: drvclkref: driver clock reference (def=0) (ushort)parm: txqhiwat: Tx fifo hi-water ratio [5000..10000] def=10000) (short)
The list of connected devices:
~ $ ls /dev/* | grep -P "pcan\d+"/dev/pcan32/dev/pcan33/dev/pcan34/dev/pcan35/dev/pcan36/dev/pcan37/dev/pcan38/dev/pcan39
udevadm
info for one device:
~ $ udevadm info --query=all --name=/dev/pcan32P: /devices/pci0000:00/0000:00:14.0/usb2/2-13/2-13.3/2-13.3.1/2-13.3.1.1/2-13.3.1.1:1.0/pcan/pcanusb32N: pcanusb32L: 0S: pcan-usb/0/can0S: pcan32S: U3-PCAN-1E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb2/2-13/2-13.3/2-13.3.1/2-13.3.1.1/2-13.3.1.1:1.0/pcan/pcanusb32E: DEVNAME=/dev/pcanusb32E: MAJOR=238E: MINOR=32E: SUBSYSTEM=pcanE: USEC_INITIALIZED=1453865341559E: DEVLINKS=/dev/pcan-usb/0/can0 /dev/pcan32 /dev/U3-PCAN-1
however, when using python-can to detect the available devices, I get the following:
In [1]: from can.interface import detect_available_configsIn [2]: print("\n".join(map(str, detect_available_configs('pcan')))){'interface': 'pcan', 'channel': 'PCAN_USBBUS1', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS2', 'supports_fd': True, 'controller_number': 0, 'device_features': 3, 'device_id': 0, 'device_name': 'PCAN-USB FD', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS3', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS4', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS5', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 1, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS6', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS7', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}{'interface': 'pcan', 'channel': 'PCAN_USBBUS8', 'supports_fd': False, 'controller_number': 0, 'device_features': 0, 'device_id': 0, 'device_name': 'PCAN-USB', 'device_type': 5, 'channel_condition': 1}
How can I know each /dev/pcanX
is mapped to which PCAN_USBBUSX
?
since in the Linux systems, the first device gets the first index and the second gets the second index etc...,
Can I assume that the first pcan device (in my case /dev/pcan32
) is mapped to PCAN_USBBUS1
and the second device /dev/pcan33
is mapped to PCAN_USBBUS2
?
etc...
I need a method to know for sure each /dev/pcan<X>
is mapped to which Python PCAN_USBBUS<X>