DeviceId

This parameter is used to distinguish between 2 or more devices of the same kind connected to a computer simultaneously. A device identifier is a persistent value stored in the flash memory of each device, i.e., the value is not lost after disconnecting the hardware.

  Important

Several devices can have the same identifier. It is up to the user to guarantee that those being used are configured with different identifiers, so that a differentiation through this value can work.

This parameter can be used when it is needed to differentiate between PCAN-USB devices connected to the same system at a given time.

Availability

It is available since PCAN-Basic version 1.0.0.

It can be retrieved without initialization since PCAN-Basic version 4.4.0.

Supported By

  Important

PCAN-PCI: Only FPGA based devices. Requires a device driver version equal to or greater than 4.2.0.

PCAN-LAN: Only devices with a firmware version equal to or greater than 2.8.2. Requires a device driver version equal to or greater than 4.2.0.

Access Mode

This parameter is read/write. It can be configured and retrieved.

Possible Values

According with the firmware version of the PCAN-USB device, this value can have a resolution of a byte (range [0...MaxValue]), or a double-word (range [0...MaxValue]).

Default Value

If this parameter was never set before, the value is the maximum value possible for the used resolution which is 255 (FFh), or 429496729 (FFFFFFFFh).

Initialization Status

Get: It can be read on initialized or uninitialized PCAN Channels.

Set: It can be set on initialized PCAN Channels only.

Example

The following code shows how to distinguish USB Channels using their device IDs:

C#
PcanChannel[] channelsToCheck = { PcanChannel.Usb01, PcanChannel.Usb02 };
uint deviceId;
PcanChannel readChannel, writeChannel;

readChannel = writeChannel = PcanChannel.None;

for (int i = 0; i < 2; i++)
{
    if (Api.GetValue(channelsToCheck[i], PcanParameter.DeviceId, out deviceId) == PcanStatus.OK)
    {
        if (deviceId == 1)
        {
            writeChannel = channelsToCheck[i];
            Console.WriteLine("The channel for writing (handle 0x{0:X}) was found.", channelsToCheck[i]);
        }
        if (deviceId == 2)
        {
            readChannel = channelsToCheck[i];
            Console.WriteLine("The channel for reading (handle 0x{0:X}) was found.", channelsToCheck[i]);
        }
    }
}

if ((readChannel != PcanChannel.None) && (writeChannel != PcanChannel.None))
{
    Console.WriteLine("Both channels were found. Starting to work . . .");
    // Do work . . . 
}
else
    Console.WriteLine("Error! Not all needed channels were found. Terminating . . .");

See Also