Important
For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.
public static TPCANStatus GetValue(
ushort Channel,
TPCANParameter Parameter,
out uint NumericBuffer,
uint BufferLength
)
Public Shared Function GetValue (
Channel As UShort,
Parameter As TPCANParameter,
<OutAttribute> ByRef NumericBuffer As UInteger,
BufferLength As UInteger
) As TPCANStatus
public:
static TPCANStatus GetValue(
unsigned short Channel,
TPCANParameter Parameter,
[OutAttribute] unsigned int% NumericBuffer,
unsigned int BufferLength
)
The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:
Use the method GetValue to get information about PCAN environment as parameters like the PCAN Channel device ID. Take in account that not all parameters are supported for all PCAN Channels. The access's type of the parameters can also be different.
For more information about the possible values that can be retrieved, see Parameter Value Definitions
The following example shows the use of GetValue(UInt16, TPCANParameter, UInt32, UInt32) method on the channel PCAN_USBBUS1 to check if the Message Filter is fully opened. 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;
UInt32 iBuffer;
strMsg = new System.Text.StringBuilder(256);
// ... channel is initialized ...
// The status of the message filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, out iBuffer, sizeof(UInt32));
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
{
// A text is shown giving information about the current status of the filter
//
switch (iBuffer)
{
case PCANBasic.PCAN_FILTER_OPEN:
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.");
break;
case PCANBasic.PCAN_FILTER_CLOSE:
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is closed.");
break;
case PCANBasic.PCAN_FILTER_CUSTOM:
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.");
break;
}
}
Dim result As TPCANStatus
Dim strMsg As System.Text.StringBuilder
Dim iBuffer As UInt32
strMsg = New System.Text.StringBuilder(256)
' ... channel is initialized ...
' The status of the message filter of the PCAN-USB Channel 1 is asked
'
result = PCANBasic.GetValue(PCANBasic.PCAN_USBBUS1, TPCANParameter.PCAN_MESSAGE_FILTER, iBuffer, CType(System.Runtime.InteropServices.Marshal.SizeOf(iBuffer), UInteger))
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
' A text is shown giving information about the current status of the filter
'
Select Case iBuffer
Case PCANBasic.PCAN_FILTER_OPEN
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.")
Case PCANBasic.PCAN_FILTER_CLOSE
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is closed.")
Case PCANBasic.PCAN_FILTER_CUSTOM
Console.WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.")
End Select
End If
TPCANStatus result;
System::Text::StringBuilder^ strMsg;
UInt32 iBuffer;
strMsg = gcnew System::Text::StringBuilder(256);
// ... channel is initialized ...
// The status of the message filter of the PCAN-USB Channel 1 is asked
//
result = PCANBasic::GetValue(PCANBasic::PCAN_USBBUS1, TPCANParameter::PCAN_MESSAGE_FILTER, iBuffer, sizeof(iBuffer));
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
{
// A text is shown giving information about the current status of the filter
//
switch (iBuffer)
{
case PCANBasic::PCAN_FILTER_OPEN:
Console::WriteLine("The message filter for the PCAN-USB, channel 1, is completely opened.");
break;
case PCANBasic::PCAN_FILTER_CLOSE:
Console::WriteLine("The message filter for the PCAN-USB, channel 1, is closed.");
break;
case PCANBasic::PCAN_FILTER_CUSTOM:
Console::WriteLine("The message filter for the PCAN-USB, channel 1, is custom configured.");
break;
}
}