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 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.
This parameter can be used when it is needed to differentiate between PCAN-USB devices connected to the same system at a given time.
It is available since PCAN-Basic version 1.0.0.
It can be retrieved without initialization since PCAN-Basic version 4.4.0.
This parameter is read/write. It can be configured and retrieved.
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]).
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).
Get: It can be read on initialized or uninitialized PCAN Channels.
Set: It can be set on initialized PCAN Channels only.
The following code shows how to distinguish USB Channels using their device IDs:
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 . . .");Dim channelsToCheck As PcanChannel() = {PcanChannel.Usb01, PcanChannel.Usb02}
Dim deviceId As UInteger
Dim readChannel, writeChannel As PcanChannel
readChannel = writeChannel = PcanChannel.None
For i = 0 To 1
If Api.GetValue(channelsToCheck(i), PcanParameter.DeviceId, deviceId) = PcanStatus.OK Then
If deviceId = 1 Then
writeChannel = channelsToCheck(i)
Console.WriteLine("The channel for writing (handle 0x{0:X}) was found.", channelsToCheck(i))
End If
If deviceId = 2 Then
readChannel = channelsToCheck(i)
Console.WriteLine("The channel for reading (handle 0x{0:X}) was found.", channelsToCheck(i))
End If
End If
Next
If readChannel <> PcanChannel.None AndAlso writeChannel <> PcanChannel.None Then
' Do work . . .
Console.WriteLine("Both channels were found. Starting to work . . .")
Else
Console.WriteLine("Error! Not all needed channels were found. Terminating . . .")
End Ifarray<PcanChannel>^ channelsToCheck = { PcanChannel::Usb01, PcanChannel::Usb02 };
UInt32 deviceId;
PcanChannel readChannel, writeChannel;
readChannel = writeChannel = PcanChannel::None;
for (int i = 0; i < 2; i++)
{
if (Api::GetValue(channelsToCheck[i], PcanParameter::DeviceId, 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 . . .");