GetValue(TPCANHandle,TPCANParameter)

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
GetValue(TPCANHandle,TPCANParameter)

Retrieves information from a PCAN Channel.

Syntax
def GetValue(
    self,
    Channel,
    Parameter)
Parameters 
Description 
Channel 
The handle of a PCAN Channel (see TPCANHandle). 
Parameter 
The code of the information to be retrieved (see TPCANParameter). 

The return value is a 2-touple. The order of the returned values is as follow: 

[0]: The method's return value as a TPCANStatus code. PCAN_ERROR_OK is returned on success. The typical errors in case of failure are:  

PCAN_ERROR_ILLPARAMVAL: 
Indicates that the parameters passed to the method are invalid. Check the parameter 'NumericBuffer'; it should point to an integer buffer. 
PCAN_ERROR_INITIALIZE: 
Indicates that the given PCAN channel was not found in the list of initialized channels of the calling application. 
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. 

[1]: The requested parameter value (the type of the value depends on the TPCANParameter requested).

Use the method GetValue to get information about PCAN environment as parameters like the Message Filter and values like the availability of a PCAN-Channel. Take in account that not all parameters are supported for all PCAN-Channels. The access's type of the parameters can also be different. 

More information about the parameters and values that can be read can be found in Parameter Value Definitions

Python Notes 

  • Class-Method: Unlike the .NET Framework, under Python a variable has to be instantiated with an object of type PCANBasic in order to use the API functionality.
  • Python's first argument convention: Under Python, 'self' is a parameter that is automatically included within the call of this method, within a PCANBasic object and hasn't to be indicated in a method call. This parameter represents the calling object itself.

The following example shows the use of the method GetValue 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. 

Note: It is assumed that the channel was already initialized. 

Python:  

# The status of the message filter of the PCAN-USB Channel 1 is asked
#
result = objPCAN.GetValue(PCAN_USBBUS1,PCAN_MESSAGE_FILTER)
if result[0] != PCAN_ERROR_OK:
    # An error occurred, get a text describing the error and show it
    #
    result = objPCAN.GetErrorText(result)
    print result
else:
    # A text is shown giving information about the current status of the filter
    #
    if result[1] == PCAN_FILTER_OPEN:
        print "The message filter for the PCAN-USB, channel 1, is completely opened."
    elif result[1] == PCAN_FILTER_CLOSE:
        print "The message filter for the PCAN-USB, channel 1, is closed."
    elif result[1] == PCAN_FILTER_CUSTOM:
        print "The message filter for the PCAN-USB, channel 1, is custom configured."
Copyright © 2017. PEAK-System Technik GmbH. All rights reserved.
Send feedback to this documentation