public static PcanStatus LookUpChannel(
string parameters,
out PcanChannel foundChannel
)
Public Shared Function LookUpChannel (
parameters As String,
<OutAttribute> ByRef foundChannel As PcanChannel
) As PcanStatus
public:
static PcanStatus LookUpChannel(
String^ parameters,
[OutAttribute] PcanChannel% foundChannel
)
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.
OK is returned on success. The typical errors in case of failure are:
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.
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.
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}");
}
Dim channel As PcanChannel = PcanChannel.None
Dim deviceType As PcanDevice = PcanDevice.PcanPci
Dim deviceId As UInt32 = 7
Dim paramters = ParameterValue.LookUp.GetCriteriaString(deviceType, deviceId, Nothing, Nothing)
' The Channel query is made with the specified criteria
'
Console.WriteLine($"Searching for PCAN Handle with type {deviceType} And device ID equals to {deviceId}.")
Dim result As PcanStatus = Api.LookUpChannel(paramters, channel)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
Api.GetErrorText(result, errorText)
Console.WriteLine(errorText)
Else
' Show the results of the search
'
If channel = PcanChannel.None Then
Console.WriteLine("No PCAN Channel matched the search criteria.")
Else
Console.WriteLine($"The handle of the PCAN Channel Is {channel}")
End If
End If
String^ errorText = String::Empty;
PcanChannel channel = PcanChannel::None;
PcanDevice deviceType = PcanDevice::PcanPci;
Nullable <UInt32> deviceId = 7;
String^ paramters = ParameterValue::LookUp::GetCriteriaString(Nullable<PcanDevice>(deviceType), Nullable<UInt32>(deviceId), Nullable<UInt32>(), nullptr);
// The Channel query is made with the specified criteria
//
Console::WriteLine("Searching for PCAN Handle with type {0} and device ID equals to {1}.", deviceType, deviceId);
PcanStatus result = Api::LookUpChannel(paramters, channel);
if (result != PcanStatus::OK)
{
// An error occurred
//
Api::GetErrorText(result, 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 {0}", channel);
}
DllNotFoundException | The underlying PCANBasic.dll library could not be found. |
PcanBasicException | The 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. |