ChannelCondition

This parameter is used to identify the state of use of a PCAN Channel by returning a flag value. For example, a connection is only possible when a PCAN Channel is available, which means:

  • It is valid: The PCAN Channel is one of the listed in the section "Supported By" below.

  • It is present: The hardware associated to a PCAN Channel is attached to the PC, recognized and registered by the device driver.

  • It is connectible: The PCAN Channel is not yet initialized, or it is currently connected by a PCAN-View application.

This parameter is useful when the availability status of a channel registered in a system at a given time must be known.

Availability

Available since PCAN-Basic version 1.0.0. Nevertheless, usability improved significantly since version 1.0.4, due to bug fixes.

The behavior of this parameter was modified with the version 4.0.0.

Supported By

Access Mode

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

Possible Values

The information about the condition of a Channel is returned as a numeric value, that matches the type ChannelCondition.

  Important

The retrieved value must be converted to the ChannelCondition type. Example (C#): ChannelCondition condition = (ChannelCondition)uintBuffer;

Default Value

Does not apply.

Initialization Status

Get: Not relevant, since this parameter is used to ask the status of a PCAN Channel.

Example

The following code shows how to ask the condition of 4 PCI Channels:

C#
PcanChannel[] channelsToCheck = { PcanChannel.Pci01, PcanChannel.Pci02, PcanChannel.Pci03, PcanChannel.Pci04 };
uint buffer;

for (int i = 0; i < 4; i++)
{
    if (Api.GetValue(channelsToCheck[i], PcanParameter.ChannelCondition, out buffer) == PcanStatus.OK)
    {
        ChannelCondition condition = (ChannelCondition)buffer;
        if ((condition & ChannelCondition.ChannelAvailable) == ChannelCondition.ChannelAvailable)
            Console.WriteLine($"The Channel {channelsToCheck[i]} is available.");
        else
            Console.WriteLine($"The Channel {channelsToCheck[i]} is NOT available.");
    }
}

See Also