public static TPCANStatus LookUpChannel(
string Parameters,
out ushort FoundChannel
)
Public Shared Function LookUpChannel (
Parameters As String,
<OutAttribute> ByRef FoundChannel As UShort
) As TPCANStatus
public:
static TPCANStatus LookUpChannel(
String^ Parameters,
[OutAttribute] unsigned short% FoundChannel
)
The return value is a TPCANStatus value.PCAN_ERROR_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 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
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.
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");
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim channelHandle As UInt16
strMsg = New System.Text.StringBuilder(256)
' Try to find a PCAN-USB device with ID 7
'
result = PCANBasic.LookUpChannel("devicetype=pcan_usb, deviceid=7", channelHandle)
If result <> TPCANStatus.PCAN_ERROR_OK Then
' 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 Then
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")
End If
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt16 channelHandle;
strMsg = gcnew System::Text::StringBuilder(256);
// Try to find a PCAN-USB device with ID 7
//
result = PCANBasic::LookUpChannel("devicetype=pcan_usb, deviceid=7", 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");
}