Hello,
I'm developing a small C application based on PCANBasic dll. At the init I loop through the possible devices (from PCAN_USBBUS1 to PCAN_USBBUS16 and from PCAN_LANBUS1 to PCAN_LANBUS16) trying to see if they are present or not to create a list of the available ones. To do that, based on the examples provided I do an un-initialize calling PCAN_Uninitialize (just to be sure there is no pending init) and then an initialize calling PCAN_Initialize: if the return is ok I read some params like HW Name, .. and I deinit the channel calling back PCAN_Uninitialize.
Everything seems to work but sometimes my application hungs at PCAN_Uninitialize or PCAN_Initialize call. I tried to add a delay but I still have the problem. I checked in the forum but I was not able to find a topic open on this type of issue.
Do you have any suggestion?
thanks
Michele
Loop through the possible devices to detect the available ones
-
- Posts: 24
- Joined: Fri 15. Mar 2019, 14:44
Re: Loop through the possible devices to detect the available ones
Hello,
you do not need to iterate anymore on all possible channels. Rather you can just use the parameter PCAN_ATTACHED_CHANNELS, which gives you already a list with all available channels. For more information check this parameter within the API documentation, or check the sample function "GetPCAN_ATTACHED_CHANNELS" within the native C++ project sample "02_getSetParameter" (Samples\Samples.zip\Console\NativeC++\02_GetSetParameter), which is delivered together with the PCAN-Basic package.
you do not need to iterate anymore on all possible channels. Rather you can just use the parameter PCAN_ATTACHED_CHANNELS, which gives you already a list with all available channels. For more information check this parameter within the API documentation, or check the sample function "GetPCAN_ATTACHED_CHANNELS" within the native C++ project sample "02_getSetParameter" (Samples\Samples.zip\Console\NativeC++\02_GetSetParameter), which is delivered together with the PCAN-Basic package.
Best regards,
Keneth
Keneth
-
- Posts: 24
- Joined: Fri 15. Mar 2019, 14:44
Re: Loop through the possible devices to detect the available ones
Hi,
thank you very much it works fine. The only issue I have is that we use PCAN usb devices but also PCAN-Ethernet Gateways and in order to distinguish them I was planning to use the device-id for the usb ones and the ip-address for the network ones because it seems to me the device id is not managed in the network ones .. or at least I cannot find in the gateway webpage a point where I can set it.
thanks for your support
michele
thank you very much it works fine. The only issue I have is that we use PCAN usb devices but also PCAN-Ethernet Gateways and in order to distinguish them I was planning to use the device-id for the usb ones and the ip-address for the network ones because it seems to me the device id is not managed in the network ones .. or at least I cannot find in the gateway webpage a point where I can set it.
thanks for your support
michele
Re: Loop through the possible devices to detect the available ones
Hello,
the ID is also handled by the PCAN-Gateways devices. This was included within the PCAN-gateway Software version 2.9.0 (August 2020) If you have a software version equal or grater to 2.9.0, then you should be able to set the Device ID using
PCAN-View, PEAK-Settings, and PCAN-Basic Note that the Device-ID cannot be set directly in the PCAN-Gateway device.
the ID is also handled by the PCAN-Gateways devices. This was included within the PCAN-gateway Software version 2.9.0 (August 2020) If you have a software version equal or grater to 2.9.0, then you should be able to set the Device ID using
PCAN-View, PEAK-Settings, and PCAN-Basic Note that the Device-ID cannot be set directly in the PCAN-Gateway device.
Best regards,
Keneth
Keneth
-
- Posts: 24
- Joined: Fri 15. Mar 2019, 14:44
Re: Loop through the possible devices to detect the available ones
Thank you very much, I was looking in the web interface. It works perfectly.
Thank you so much for the support
regards
Michele
Thank you so much for the support
regards
Michele
Re: Loop through the possible devices to detect the available ones
You are welcome. Closed.
Best regards,
Keneth
Keneth