PCAN USB Multiple Hardware same PC

A free API for the communication with control devices according to UDS (ISO 14229-1)
Shail
Posts: 25
Joined: Tue 28. Apr 2020, 10:09

PCAN USB Multiple Hardware same PC

Post by Shail » Tue 18. Aug 2020, 05:43

Hello,

WE have 2 PCAN USB Hardware which is connected to same PC.

Question :
1) How to differentiate between that which one is active?

2) What is the significance of this USB PCAN Channel? When we can use PUDS_USBBUS2 ?
#define PUDS_USBBUS1 0x51U // PCAN-USB interface, channel 1
#define PUDS_USBBUS2 0x52U // PCAN-USB interface, channel 2
#define PUDS_USBBUS3 0x53U // PCAN-USB interface, channel 3

3) What is the significance of device id in PCAN View?
For Example : We have set device id to 0x52 how to make sure same PCAN USB Hardware used via SW?

M.Heidemann
Sales & Support
Sales & Support
Posts: 465
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN USB Multiple Hardware same PC

Post by M.Heidemann » Tue 18. Aug 2020, 11:01

Hello,

1)

You could use the PEAK-Hardware applet (Via windows control panel, symbolic view) and
have a look at the pcanbaisc tab:
UDS_ActiveDevice.PNG
UDS_ActiveDevice.PNG (17.67 KiB) Viewed 959 times
Initialized devices will be listed here.

You could also iterate through all hardware handels and use "GetStatus" to see if an device is active.


2)
Those are handles representing hardware present, if you want to have influence over which handles
these devices receive, please have a look at the following forum thread:

viewtopic.php?f=120&t=125

This will show you how to set device-ids and use them to permanently bind a hardware handle to it via a registry key.

3)
No, those values are whats behind the handle defintions (aka. what the driver receives when asked for a specific channel).

Read the forum post mentioned above.

When using PnP (Plug&Play) devices the hardware handle is usually assigned starting at 16 and then counting down.
This means the first USB-Adapter will get Hardware-Handle16, the second adapter gets HardwareHandle15, the third Adapter HardwareHandle14 etc.
With PCAN-Basic the application that is started first uses Handle "PCAN_USBBUS1" = 0x51, the application that is started next will use Handle "PCAN_USBBUS2" = 0x52 etc..
This results in the following assignment scheme:
HardwareHandle 16 -> PCAN_USBBUS1 0x51
HardwareHandle 15 -> PCAN_USBBUS2 0x52
HardwareHandle 14 -> PCAN_USBBUS3 0x53

If you want for example the device with 0x52 to be PUDS_USBBUS2 permanently, do the following, like described in the forum post i mentioned:

Under the following path a new reg-key must be created.

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\pcan_usb]

if you want to use id 0x52h:

"Hardware15"="0x201,0x52,0"
HardwareHandle.PNG
HardwareHandle.PNG (1.54 KiB) Viewed 959 times
Please report back to me if this was helpful to you.

Best Regards

Marvin

Ferran Mercader
Posts: 3
Joined: Tue 18. Aug 2020, 13:32

Re: PCAN USB Multiple Hardware same PC

Post by Ferran Mercader » Tue 18. Aug 2020, 14:04

Hello M. Heidemann,

I'm working on the same configuration, 2 PCAN USB in same PC, reading different buses simultaneously.
I've been following your instructions but there is a point I can not achieve:
When I have two devices connected, then yes, 'A' is always PCAN_USBBUS1 and 'B' is always PCAN_USBBUS2, doesn't matter the order in which I connected them.
But when I connect only one, then it will always be PCAN_USBBUS1.
As you said, I want 'B' to be PCAN_USBBUS2 permanently, although it's the only devie connected.

(The point is that I want to "match" one device to one CAN bus, so I will be able to know from where wait for a specific message)

How can I solve it? Am I doing something wrong?
By the way, I'm using PCANBasic.py

Thank you very much for your attention.

Ferran
regedit.PNG
regedit.PNG (28.26 KiB) Viewed 948 times
PCANview.PNG
PCANview.PNG (70.6 KiB) Viewed 948 times
PCANview2.PNG
PCANview2.PNG (70.83 KiB) Viewed 948 times

M.Heidemann
Sales & Support
Sales & Support
Posts: 465
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN USB Multiple Hardware same PC

Post by M.Heidemann » Tue 18. Aug 2020, 14:23

Hello Ferran,

Did you reboot your machine since setting the device id?

Also, PCANBasic will, if only 1 device is connected, resort to the default hardware-handle scheme.

So the first device connected will be PCAN_USBBUS1 if not other device is connected.

Best Regards

Marvin

Ferran Mercader
Posts: 3
Joined: Tue 18. Aug 2020, 13:32

Re: PCAN USB Multiple Hardware same PC

Post by Ferran Mercader » Tue 18. Aug 2020, 15:46

Hello M.Heidemann,

Yes, I rebooted.

So there is no way to avoid this resorting?

Thank you for your quick answer.

Ferran

F.Vergnaud
Software Development
Software Development
Posts: 176
Joined: Mon 9. Sep 2013, 12:21

Re: PCAN USB Multiple Hardware same PC

Post by F.Vergnaud » Tue 18. Aug 2020, 16:58

Hello Ferran,

As Marvin said if you have only one USB device, the handle will always be PUDS_USBBUS1.
But there are possible workarounds to your problem. The device ID is your own value to identify devices, so:
- you can identify the device you are connected to within your application via the PCAN-Basic parameter PCAN_DEVICE_ID (previously known as device number).
- or before connecting, use PCAN-Basic and the parameter PCAN_ATTACHED_CHANNELS to list all the connected devices, then connect to the one that matches your requested device id.

You can find more information on those parameters in PCAN-Basic documentation.
Best regards,
Fabrice

Ferran Mercader
Posts: 3
Joined: Tue 18. Aug 2020, 13:32

Re: PCAN USB Multiple Hardware same PC

Post by Ferran Mercader » Wed 19. Aug 2020, 11:41

Hello F. Vergnuad,

Yes, I'm working on PCAN_DEVICE_ID workaround. It works for me.
Thank you very much for the support!

Ferran

johngassel
Posts: 3
Joined: Thu 3. Dec 2020, 17:15

Re: PCAN USB Multiple Hardware same PC

Post by johngassel » Thu 3. Dec 2020, 17:21

I am going to have to solve the same problem as mentioned here but my system is running Linux. Is there a way to program the Device ID without using PCAN-View software?

Also, my system will have both devices permanently connected (using PCAN chips, not usb modules) so how can I distinguish which is which at any point when programming the ID?

Thanks!

M.Heidemann
Sales & Support
Sales & Support
Posts: 465
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN USB Multiple Hardware same PC

Post by M.Heidemann » Fri 4. Dec 2020, 07:59

Hello!

You might want to check the Linux-Section of our Forum, the PCAN-UDS API is only available for Windows
and therefore no Linux-specific threads will come up here.

Are you using our mainline-driver (integrated in kernel) or do you use
our PCAN-Linux driver?

If you use the latter, do you use it as CharDev or NetDev?

One thread that explains how to use to set a device id and use the assign-parameter can be found here,
this feature is only implemented in the PCAN-Linux Driver, so it would be relevant to know if you are currently using
the mainline kernel driver or the PCAN-Linux driver:

viewtopic.php?f=59&t=6259


As to your second question:

Can you please elaborate to which "PCAN-Chip" device you are refering to (IPEH-XXXXXX)?

We carry two products with that moniker and it will be easier to help knowing which
device exactly is used.

Best Regards

Marvin

johngassel
Posts: 3
Joined: Thu 3. Dec 2020, 17:15

Re: PCAN USB Multiple Hardware same PC

Post by johngassel » Fri 4. Dec 2020, 15:21

Hi Marvin,

Thanks for the quick reply. I've got a question out to our software team regarding which Linux driver we're using. I'm not quite sure, but I'm guessing it's probably the default mainline-driver.

I can answer your second question though. We have part number: IPEH-004025. I noticed someone else in the thread you linked mentioned this:
AFAIK using a two channel card with the main line kernel driver should also work without mixing canX devices during different bootups.
We are designing our own COM Express carrier board so we have some flexibility in which part we use. It could be PCIE or USB. If there's a 2 chip solution that is cheaper or easier to integrate with software I'd be open to using that instead.

Cheers,
John

Post Reply