Tip
The Api class offers a method as a shortcut for using these two parameters, GetAttachedChannels. Use this method instead for simplicity.
This parameter is used to get information about all PCAN Channels attached to a system in a single call. It is closely tied to another parameter, AttachedChannelsCount, which returns the number of existing channels. This information is needed for building the buffer that must be passed to the GetValue, method, to retrieve the information about the available Channels.
This parameter can be used to enumerate all existing PCAN Channels in a PC at a given time.
It is available since PCAN-Basic version 4.4.0.
None Channel: Information about available Channels is not tied to any Channel, i.e. no specific Channel can be used for this query.
This parameter can only be read. It cannot be modified.
An array of PcanChannelInformation elements.
Does not apply.
Get: Not relevant since this parameter is not Channel dependent.
The following code shows how to get information about all currently attached PCAN Channels:
uint channelsCount;
if (Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, out channelsCount) == PcanStatus.OK)
{
Console.WriteLine($"Total of {channelsCount} channels were found:");
if (channelsCount > 0)
{
PcanChannelInformation[] channels = new PcanChannelInformation[channelsCount];
if (Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsInformation, channels) == PcanStatus.OK)
{
for (int i = 0; i < channelsCount; i++)
{
Console.WriteLine("{0}) ---------------------------\n", i + 1);
Console.WriteLine(" Name: {0}", channels[i].DeviceName);
Console.WriteLine(" Handle: 0x{0:X}", channels[i].ChannelHandle);
Console.WriteLine(" Controller: {0}", channels[i].ControllerNumber);
Console.WriteLine(" Condition: {0}", channels[i].ChannelCondition);
Console.WriteLine(" . . . . .");
}
}
}
}Dim channelsCount As UInteger
If Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsCount, channelsCount) = PcanStatus.OK Then
Console.WriteLine($"Total of {channelsCount} channels were found:")
If channelsCount > 0 Then
Dim channels = New PcanChannelInformation(channelsCount - 1) {}
If Api.GetValue(PcanChannel.None, PcanParameter.AttachedChannelsInformation, channels) = PcanStatus.OK Then
For i As Integer = 0 To channelsCount - 1
Console.WriteLine("{0}) ---------------------------" & vbLf, i + 1)
Console.WriteLine(" Name: {0}", channels(i).DeviceName)
Console.WriteLine(" Handle: 0x{0:X}", channels(i).ChannelHandle)
Console.WriteLine(" Controller: {0}", channels(i).ControllerNumber)
Console.WriteLine(" Condition: {0}", channels(i).ChannelCondition)
Console.WriteLine(" . . . . .")
Next
End If
End If
End IfUInt32 channelsCount;
if (Api::GetValue(PcanChannel::None, PcanParameter::AttachedChannelsCount, channelsCount) == PcanStatus::OK)
{
Console::WriteLine("Total of {0} channels were found:", channelsCount);
if (channelsCount > 0)
{
array<PcanChannelInformation^>^ channels = gcnew array<PcanChannelInformation^>(channelsCount);
if (Api::GetValue(PcanChannel::None, PcanParameter::AttachedChannelsInformation, channels) == PcanStatus::OK)
{
for (int i = 0; i < channelsCount; i++)
{
Console::WriteLine("{0}) ---------------------------\n", i + 1);
Console::WriteLine(" Name: {0}", channels[i]->DeviceName);
Console::WriteLine(" Handle: 0x{0:X}", channels[i]->ChannelHandle);
Console::WriteLine(" Controller: {0}", channels[i]->ControllerNumber);
Console::WriteLine(" Condition: {0}", channels[i]->ChannelCondition);
Console::WriteLine(" . . . . .");
}
}
}
}