PCANBasicLookUpChannel Method

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

Definition

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
public static TPCANStatus LookUpChannel(
	string Parameters,
	out ushort 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  UInt16
Buffer for returning the PCAN Channel (see PCAN Handle Definitions), when found. It contains the value PCAN_NONEBUS if not found.

Return Value

TPCANStatus

The return value is a TPCANStatus value.PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

Remarks

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

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

The current supported parameters and their value ranges are described in Look Up Parameter Definitions

Example

The following example shows the use of SetValue(UInt16, TPCANParameter, String, UInt32) method to get the handle of an USB device with ID 7. 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#
TPCANStatus result;
System.Text.StringBuilder strMsg;
UInt16 channelHandle;

strMsg = new System.Text.StringBuilder(256);

// Try to find a PCAN-USB device with ID 7
//
result = PCANBasic.LookUpChannel("devicetype=pcan_usb, deviceid=7", out channelHandle);
if (result != TPCANStatus.PCAN_ERROR_OK)
{
    // An error occurred, get a text describing the error and show it
    //
    PCANBasic.GetErrorText(result, 0, strMsg);
    Console.WriteLine(strMsg.ToString());
}
else
{
    if (channelHandle != PCANBasic.PCAN_NONEBUS)
        Console.WriteLine("The channel handle for the PCAN-USB with ID=7 was found");
    else
        Console.WriteLine("A PCAN-USB device with ID=7 is not available");
}

See Also