ApiLookUpChannel Method

Finds the handle of a PCAN Channel that matches the given parameters.

Definition

Namespace: Peak.Can.Basic
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
public static PcanStatus LookUpChannel(
	string parameters,
	out PcanChannel foundChannel
)

Parameters

parameters  String
A comma-separated string of search parameters, that is, parameter name/value pairs to be matched within a PCAN Channel.
foundChannel  PcanChannel

Contains the matching PCAN Handle, when found in the list of attached Channels.

foundChannel is only valid, if the returned value of this method is OK.

Return Value

PcanStatus

OK is returned on success. The typical errors in case of failure are:

  • InvalidValue: Indicates that parameters contains an invalid value.

Remarks

The parameters string must contain name/value pairs separated with a '=' character.

Each name/value pair must be separated with a ',' character.

The current supported parameters and their value ranges are described within the ParameterValueLookUp class definition.

Example

The following example shows the use of the LookUpChannel method. The handle of a PCAN Channel of type PCI and ID 7 is requested.

In case of failure, the returned code will be translated to a text (according with the operating system language) in English, German, Italian, French or Spanish, and it will be shown to the user.

C#
PcanChannel channel = PcanChannel.None;
PcanDevice deviceType = PcanDevice.PcanPci;
uint deviceId = 7;

string paramters = ParameterValue.LookUp.GetCriteriaString(deviceType, deviceId, null, null);

// The Channel query is made with the specified criteria
//
Console.WriteLine($"Searching for PCAN Handle with type {deviceType} and device ID equals to {deviceId}.");
PcanStatus result = Api.LookUpChannel(paramters, out channel);
if (result != PcanStatus.OK)
{
    // An error occurred
    //
    Api.GetErrorText(result, out var errorText);
    Console.WriteLine(errorText);
}
else
{
    // Show the results of the search
    //
    if (channel == PcanChannel.None)
        Console.WriteLine("No PCAN Channel matched the search criteria.");
    else
        Console.WriteLine($"The handle of the PCAN Channel is {channel}");
}

Exceptions

DllNotFoundExceptionThe underlying PCANBasic.dll library could not be found.
PcanBasicExceptionThe execution of a PCAN-Basic related check operation ended with an unexpected result. Typically, this exception is triggered when a device driver is not installed or is not up to date.

See Also