PCAN-Basic API LookUpChannel for multiple USBs

This forum covers issues concerning multiple software products.
Post Reply
Posts: 1
Joined: Mon 21. Feb 2022, 23:44

PCAN-Basic API LookUpChannel for multiple USBs

Post by RiaanOos » Mon 21. Feb 2022, 23:55

I am new to working with CAN and PCAN.

I need to discover all of the USB attached devices and start a new thread for each (in order to tx/rx).

Using the LookUpChannel I can find the first USBdevice (0x51), but I cant seem to find any other. If I manually just change the transmit example to PCAN_USBBU2, I can get to the second device, so I know it is there and working.

LookUpChannel seems to take a string as input. One can specify the device type, but I tried adding a range to the other fields, but I always get 0x51 no matter what.

How do I get the other USB handles?

User avatar
Sales & Support
Sales & Support
Posts: 1545
Joined: Fri 10. Sep 2010, 19:34

Re: PCAN-Basic API LookUpChannel for multiple USBs

Post by U.Wilhelm » Tue 22. Feb 2022, 08:16

In the PCAN-Basic API, you will find a folder with Sample code.
Also this one PCAN-Basic API\Samples\Console\NativeC++\01_LookUpChannel\
This sampel show how to use the functionality of the LookUpChannel. It is available for C++/C#/Python/Delphi(Lazarus)/VB
PEAK-System Technik
Technical Support Team

Sales & Support
Sales & Support
Posts: 783
Joined: Fri 20. Sep 2019, 13:31

Re: PCAN-Basic API LookUpChannel for multiple USBs

Post by PEAK-Supporter » Tue 22. Feb 2022, 08:16

Adding to U.Wilhelms answer:

You are also using the wrong function for your intended purpose.

CAN_LookUpChannel is is used to return 1 channels matching
the given parameters the closest.

You'll have to use the parameter PCAN_ATTACHED_CHANNELS_COUNT,
here an example given in the PCANBasic parameter documentation (page 22)

Code: Select all

uint channelsCount;
channelsCount, 4) == TPCANStatus.PCAN_ERROR_OK)
 Console.WriteLine("Total of {0} channels were found:", channelsCount);
 if (channelsCount > 0)
 TPCANChannelInformation[] channels = new TPCANChannelInformation[channelsCount];
 if (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS, channels) == 
 for (int i = 0; i < channelsCount; i++)
 Console.WriteLine("{0}) ---------------------------\n", i + 1);
 Console.WriteLine(" Name: {0}", channels[i].device_name);
 Console.WriteLine(" Handle: 0x{0:X}", channels[i].channel_handle);
 Console.WriteLine("Controller: {0}", channels[i].controller_number);
 Console.WriteLine(" Condition: {0}", channels[i].channel_condition);
 Console.WriteLine(" . . . . .");

The GUI examples use the same worflow, you can also have a look at their implementation.

Best Regards


Post Reply