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,
TPCANChannelInformation[] ChannelsBuffer
)
Public Shared Function GetValue (
Channel As UShort,
Parameter As TPCANParameter,
ChannelsBuffer As TPCANChannelInformation()
) As TPCANStatus
public:
static TPCANStatus GetValue(
unsigned short Channel,
TPCANParameter Parameter,
array<TPCANChannelInformation>^ ChannelsBuffer
)
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 information about the PCAN Channels current attached to the PC. 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, TPCANChannelInformation) method on the channel PCAN_USBBUS1 to retrieve the configured message filter as 11-bit acceptance code and mask. 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.
uint channelsCount;
// The amount of available channels is asked, in order to create the buffer for their information
//
if (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS_COUNT, out channelsCount, 4) == TPCANStatus.PCAN_ERROR_OK)
{
Console.WriteLine("Total of {0} channels were found:", channelsCount);
if (channelsCount > 0)
{
// The information of the current available channels is retrieved
//
TPCANChannelInformation[] channels = new TPCANChannelInformation[channelsCount];
if (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS, channels) == TPCANStatus.PCAN_ERROR_OK)
{
for (int i = 0; i < channelsCount; i++)
{
Console.WriteLine("{0}) ---------------------------\n", i + 1);
Console.WriteLine(" Name: {0}", channels[i].device_name);
Console.WriteLine(" Handle: 0x{0:X}", channels[i].channel_handle);
Console.WriteLine("Controller: {0}", channels[i].controller_number);
Console.WriteLine(" Condition: {0}", channels[i].channel_condition);
Console.WriteLine(" . . . . .");
}
}
}
}
Dim channelsCount As UInt32
' The amount of available channels Is asked, in order to create the buffer for their information
'
If PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS_COUNT, channelsCount, 4) = TPCANStatus.PCAN_ERROR_OK Then
Console.WriteLine("Total of {0} channels were found:", channelsCount)
If channelsCount > 0 Then
' The information of the current available channels is retrieved
'
Dim channels(channelsCount) As TPCANChannelInformation
If (PCANBasic.GetValue(PCANBasic.PCAN_NONEBUS, TPCANParameter.PCAN_ATTACHED_CHANNELS, channels) = TPCANStatus.PCAN_ERROR_OK) Then
' Information about each available channels is shown
'
For i As Integer = 0 To channelsCount - 1
Console.WriteLine("{0}) ---------------------------\n", i + 1)
Console.WriteLine(" Name: {0}", channels(i).device_name)
Console.WriteLine(" Handle: 0x{0:X}", channels(i).channel_handle)
Console.WriteLine("Controller: {0}", channels(i).controller_number)
Console.WriteLine(" Condition: {0}", channels(i).channel_condition)
Console.WriteLine(" . . . . .")
Next
End If
End If
End If
UInt32 channelsCount;
// The amount of available channels is asked, in order to create the buffer for their information
//
if (PCANBasic::GetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_ATTACHED_CHANNELS_COUNT, channelsCount, sizeof(channelsCount)) == TPCANStatus::PCAN_ERROR_OK)
{
Console::WriteLine("Total of {0} channels were found:", channelsCount);
if (channelsCount > 0)
{
// The information of the current available channels is retrieved
//
array <TPCANChannelInformation> ^channels = gcnew array<TPCANChannelInformation>(channelsCount);
if (PCANBasic::GetValue(PCANBasic::PCAN_NONEBUS, TPCANParameter::PCAN_ATTACHED_CHANNELS, channels) == TPCANStatus::PCAN_ERROR_OK)
{
for (int i = 0; i < channelsCount; i++)
{
Console::WriteLine("{0}) ---------------------------\n", i + 1);
Console::WriteLine(" Name: {0}", channels[i].device_name);
Console::WriteLine(" Handle: 0x{0:X}", channels[i].channel_handle);
Console::WriteLine("Controller: {0}", channels[i].controller_number);
Console::WriteLine(" Condition: {0}", channels[i].channel_condition);
Console::WriteLine(" . . . . .");
}
}
}
}