Python GetAvailableHardware() and can_available_hardware_t Objects

Professional CAN and CAN FD Development Package for Windows®
Locked
Sambo
Posts: 5
Joined: Tue 17. Jun 2025, 23:10

Python GetAvailableHardware() and can_available_hardware_t Objects

Post by Sambo » Mon 23. Jun 2025, 21:34

This function returns a list of can_available_hardware_t objects.
These objects contain the following properties:
- "device"
- "hw"
- "name"
- "type"
- "channel"
- "reserved"
I find that the "device" property is always 3 for every device connected.
The PCAN-API_4_Documentation.pdf says this is "The device on which this channel is available."
I had 2 PCAN-USB and 1 PCAN_FD-USB connected. I unplugged one, but the "device" property was still 3 for the two remaining can_available_hardware_t objects.

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: Python GetAvailableHardware() and can_available_hardware_t Objects

Post by K.Wagner » Tue 24. Jun 2025, 13:54

Hello,

the device ID is something "not unique" that can be set as the user needs. If you set the same ID to all your devic, then you will get also this information using the getavailableHardware function. You can change the device ID using either the PEAK Settings applet or the PCAn-View. here a picture of this in PCAN-View:
PCAN-View.png
PCAN-View.png (83.31 KiB) Viewed 12752 times
Best regards,
Keneth

Sambo
Posts: 5
Joined: Tue 17. Jun 2025, 23:10

Re: Python GetAvailableHardware() and can_available_hardware_t Objects

Post by Sambo » Wed 25. Jun 2025, 01:24

Thanks for your response, K.Wagner, but I don't see the DeviceID property to be in the list of Available Hardware Devices.
I found my answer playing with C#, which has better type clarity.
I found the "device" property to be a PcanDevice enum value.
A device type of 3 corresponds to PcanDevice.Usb

K.Wagner
Software Development
Software Development
Posts: 1082
Joined: Wed 22. Sep 2010, 13:36

Re: Python GetAvailableHardware() and can_available_hardware_t Objects

Post by K.Wagner » Wed 25. Jun 2025, 09:40

Hello,

glad to see you have found what you needed. All this information is in the documentation. It is easier looking at it first, before looking the code. Closed.
Best regards,
Keneth

Locked