AttachedChannelsInformation

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.

  Tip

The Api class offers a method as a shortcut for using these two parameters, GetAttachedChannels. Use this method instead for simplicity.

Availability

It is available since PCAN-Basic version 4.4.0.

Supported By

  • None Channel: Information about available Channels is not tied to any Channel, i.e. no specific Channel can be used for this query.

Access Mode

This parameter can only be read. It cannot be modified.

Possible Values

An array of PcanChannelInformation elements.

Default Value

Does not apply.

Initialization Status

Get: Not relevant since this parameter is not Channel dependent.

Example

The following code shows how to get information about all currently attached PCAN Channels:

C#
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(" . . . . .");
            }
        }
    }
}

See Also