Reading USB's Device Number

USB to CAN Interface
Post Reply
Truhlar
Posts: 2
Joined: Thu 3. Mar 2016, 12:14

Reading USB's Device Number

Post by Truhlar » Thu 3. Mar 2016, 12:30

Hi,

I want to read USB's Device Number from adapter. Unfortunately this is possible only when device is initialized first (otherwise I get error message PCAN_ERROR_INITIALIZE). Is there some possibility to get this ID without initialization? I want to get list of available devices in system including this IDs, but without previous initialization. I will mark each device with it's assigned ID, so user will be able to select which device to initialize by it's ID.

Or another approach (maybe better). Is possible to read device serial number (which is already printed on adapter)?

regards

Jan

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

Re: Reading USB's Device Number

Post by K.Wagner » Thu 3. Mar 2016, 15:40

Hello Jan,
Truhlar wrote: Is there some possibility to get this ID without initialization?
No. You first need to initialize a channel in order to read its Device-ID.
Truhlar wrote: Is possible to read device serial number (which is already printed on adapter)?
No. The serial number cannot be read.

You can do a loop and initialize each available channel, get the associated ID, and uninitialize it again. This should'n have a negative impact in your application.
Best regards,
Keneth

Truhlar
Posts: 2
Joined: Thu 3. Mar 2016, 12:14

Re: Reading USB's Device Number

Post by Truhlar » Fri 4. Mar 2016, 10:46

Thank you for your answer.

I will use the initialize, read, uninitialize sequence with listen-only mode (to prevent disturb communication on the connected bus).

But one interesting behaviour. When I do this sequence, the indication LED on adapter is switched off temporarily (it is blinking when adapter stays initialized). But when I run your PcanFlash application and select "connect", then list of available devices is shown (including device IDs), but LED lite without interruption all the time from running application till connection. This seems like the PcanFlash is able to read the device ID without initialization (or with initialization but with some special mode, when LED is not affected).

Blinking of adapter LED while scanning for device list is not significant problem, but this difference (between PcanFlash and my application behaviour) leads me into belief, that PcanFlash is able to read device ID without initialization.

regards

Jan

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

Re: Reading USB's Device Number

Post by K.Wagner » Fri 4. Mar 2016, 11:27

Hello Jan,

the PCANFlash doesn't use the PCAN-Basic for communication. It uses the PCAN-API, which is another CAN library from PEAK-System. This library offers many more possibilities, but it is also not that easy to use as the PCAN-Basic. Nevertheless, the main difference is that the PCAN-Basic is fee free, while the PCAN-API must be buyed. It is part of the PCAN-developer package. More info about it can be found here: PCAN-Developer
Best regards,
Keneth

Post Reply