But sometimes, specially if your are programming an application (using PCAN-Basic, PLIN-API, etc.) to work with several devices on the same computer, you may need to unequivocally differentiate the available devices, that is, you need to know the handle of a device in every moment, not worrying about when it was plugged in or if the computer was restarted, etc.
If you need to use fixed hardware handles within the CAN part of an USB Pro, please see this topic. Otherwise, if you need fixed hardware handles using the LIN Part of an USB Pro, keep reading.
The best way to explain this is with a practical example. Imaginate that you have an application which has to communicate with the first LIN channel of a specific PCAN-USB Pro device. You could do the following:
First of all, each LIN Channel has a Hardware-ID that can be configured. This ID has a size of 4 bytes and can be changed using the current version of the PEAK Control Panel Applet.
Lets say you have a PCAN-USB pro Device with it first LIN Channel configured with the ID 10:
After you have set the ID, a few values must be added in the Registry in order to create and fix a desired hardware handle. By the way, the LIN hardware handles are assigned beginning with 1. Since such a handle has a size of two bytes, you can use a handle value of up to 65535.
The registry entry for our example looks like:
The name of the created registry value tells the LIN driver which handle will be fixed. In our example we are fixing the handle 1:
Hardware1 --> LIN-Hardware Handle 1
The data of a created registry value tells the LIN driver which physical hardware (LIN channel on a PCAN-USB Pro device) must be associated to the handle specified within the value name. In our example, the hardware handle 1 will exists only when the LIN Hardware with ID 10 is available/plugged-in.
...And... that is it. After restarting the computer (or disconnecting and reconnecting again your hardware) your application will always communicate with the same LIN channel when connecting to the Hardware handle 1, indifferently of how many PCAN-USB Pro are connected to the computer or their plugging order.
Ensure that the IDs that you use for each hardware (each LIN channel of each PCAN-USB Pro device used) are unique when connected in the same machine. Having duplicated IDs cause undesired behaviors
If you see the pictures again you will see that there is a second hardware fixed (Hardware handle 2 / Hardware ID 0). This is intended to show that it is not needed to use consecutive hardware handles in order to fix them, and that the channels can be physically found even in different devices.