public static PcanStatus GetValue(
PcanChannel channel,
PcanParameter parameter,
out string buffer
)
Public Shared Function GetValue (
channel As PcanChannel,
parameter As PcanParameter,
<OutAttribute> ByRef buffer As String
) As PcanStatus
public:
static PcanStatus GetValue(
PcanChannel channel,
PcanParameter parameter,
[OutAttribute] String^% buffer
)
Contains the requested string value.
buffer 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:
Use GetValue(PcanChannel, PcanParameter, String) to get the value of parameters like the ApiVersion, and BitrateFdInformation, among others.
Not all parameters are supported for all PCAN Channels. Using a parameter with a non-compatible Channel ends with an error.
Not all parameters have read access. Using a write-only parameter with GetValue ends with an error.
The value of some parameters can only be retrieved if the channel is initialized. For more information see the PcanParameter section.
The following example shows the use of the GetValue(PcanChannel, PcanParameter, String) method using the USB interface (first PCAN-USB hardware). The name of the hardware represented by a PCAN Channel 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.Usb01;
// The name of the hardware represented by the given handle is retrieved
//
PcanStatus result = Api.GetValue(channel, PcanParameter.HardwareName, out string name);
if (result != PcanStatus.OK)
{
// An error occurred
//
Api.GetErrorText(result, out var errorText);
Console.WriteLine(errorText);
}
else
{
// The device ID is shown
//
Console.WriteLine($"The name of the hardware represented by the handle {channel} is: {name}.");
}
Dim channel As PcanChannel = PcanChannel.Usb01
' The name of the hardware represented by the given handle is retrieved
'
Dim name As String = Nothing
Dim result As PcanStatus = Api.GetValue(channel, PcanParameter.HardwareName, name)
' An error occurred
'
Dim errorText = Nothing
If result <> PcanStatus.OK Then
Api.GetErrorText(result, errorText)
Console.WriteLine(errorText)
Else
' The device ID is shown
'
Console.WriteLine($"The name of the hardware represented by the handle {channel} is: {name}.")
End If
PcanChannel channel = PcanChannel::Usb01;
String^ errorText;
String^ name;
// The name of the hardware represented by the given handle is retrieved
//
PcanStatus result = Api::GetValue(channel, PcanParameter::HardwareName, name);
if (result != PcanStatus::OK)
{
// An error occurred, get a text describing the error and show it
//
Api::GetErrorText(result, errorText);
Console::WriteLine(errorText);
}
else
// The device ID is shown
//
Console::WriteLine("The name of the hardware represented by the handle {0} is: {1}.", channel, name);
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. |