PCANBasicGetValue(UInt16, TPCANParameter, TPCANChannelInformation) Method

Retrieves a PCAN Channel value.

Definition

Namespace: Peak.Can.Basic.BackwardCompatibility
Assembly: PCANBasic.NET (in PCANBasic.NET.dll) Version: 4.9.0
C#
public static TPCANStatus GetValue(
	ushort Channel,
	TPCANParameter Parameter,
	TPCANChannelInformation[] ChannelsBuffer
)

Parameters

Channel  UInt16
The handle of a PCAN Channel (see PCAN Handle Definitions).
Parameter  TPCANParameter
The code of the information to be retrieved.
ChannelsBuffer  TPCANChannelInformation
The buffer to return information about the current attached PCAN Channels.

Return Value

TPCANStatus

The return value is a TPCANStatus value. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:

  • PCAN_ERROR_INITIALIZE: Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application.
  • PCAN_ERROR_ILLPARAMVAL: Indicates that one or more parameters passed to the method are invalid.
  • PCAN_ERROR_ILLHW: Indicates that the given PCAN Channel is not available.
  • PCAN_ERROR_ILLHANDLE: Indicates that the given PCAN Channel is not valid.
  • PCAN_ERROR_ILLPARAMTYPE: Indicates that the requested information is not available for the given PCAN Channel. Check the value of Parameter; some values are not available for all PCAN-Channels or cannot be read.

Remarks

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

  Important

For more information about each available TPCANParameter, please refer to the companion PDF documentation PCAN-Parameter_Documentation.pdf.

Example

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.

C#
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(" . . . . ."); 
            } 
        } 
    } 
}

See Also