Hi all,
At the moment I have an application utilizing two PCAN-USB adapters. Is it possible to create an environment where rather than the the first device to be plugged in is identified by channel 0x51, the second by 0x52, etc., the channels are linked to the physical ports?
So if the device is plugged in to the front right USB port it will operate on channel 0x51, back right 0x52, front left 0x53, and so on?
Thank you for any help!
Fixed /dev identifier to physical USB port
- PEAK-Support
- Sales & Support
- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Re: Fixed /dev identifier to physical USB port
Please see here
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------
Re: Fixed /dev identifier to physical USB port
Hi,
I had found that guide but it is for Windows. I am working in a Linux environment.
I had found that guide but it is for Windows. I am working in a Linux environment.
Re: Fixed /dev identifier to physical USB port
Hi,
you have to set an unique device number to each PCAN-USB, and use the udev rules to create the needed devices. Please use driver version 8.x and have a look in the manual on page 12-16 for more details.
regards
Michael
you have to set an unique device number to each PCAN-USB, and use the udev rules to create the needed devices. Please use driver version 8.x and have a look in the manual on page 12-16 for more details.
regards
Michael
Re: Fixed /dev identifier to physical USB port
Hi,
Using a Windows machine I gave my two devices unique device IDs.
As far as the devices go, I was working on a workaround before your response. To check which physical adapter is at each channel I:
- Loop through each channel and check its channel status.
- If it is available I initialize it.
- Then I use GetValue to query the device ID (which required modifying libpcanbasic.cpp, see here)
- Save the channel/device id pair and uninitialize the channel.
This works well the first time after the USB devices are plugged in. Any time after that errno = 2 is set after the ioctl() call in CAN_GetValue(). The strerror result is "No such file or directory". Once the devices are unplugged/plugged in again it works once.
Am I missing something? Any thoughts?
Thanks.
Using a Windows machine I gave my two devices unique device IDs.
As far as the devices go, I was working on a workaround before your response. To check which physical adapter is at each channel I:
- Loop through each channel and check its channel status.
- If it is available I initialize it.
- Then I use GetValue to query the device ID (which required modifying libpcanbasic.cpp, see here)
- Save the channel/device id pair and uninitialize the channel.
This works well the first time after the USB devices are plugged in. Any time after that errno = 2 is set after the ioctl() call in CAN_GetValue(). The strerror result is "No such file or directory". Once the devices are unplugged/plugged in again it works once.
Am I missing something? Any thoughts?
Thanks.
Re: Fixed /dev identifier to physical USB port
I went at the problem from another direction and it is working well now...
Rather than query each device for its number, I make a system call to read the /proc/pcan file and parse it from there. Specifically, 'cat /proc/pcan | grep 0x001c' since it is the same for all USB devices.
From here I can get the channel from *n and the device ID from irq, no need for CAN_GetValue calls.
Rather than query each device for its number, I make a system call to read the /proc/pcan file and parse it from there. Specifically, 'cat /proc/pcan | grep 0x001c' since it is the same for all USB devices.
From here I can get the channel from *n and the device ID from irq, no need for CAN_GetValue calls.