SetValue(TPCANHandle, TPCANParameter, Object)

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
SetValue(TPCANHandle, TPCANParameter, Object)

Sets a configuration or information value within a PCAN Channel.

Syntax
def SetValue(
    self,
    Channel,
    Parameter,
    Buffer)
Parameters 
Description 
Channel 
The handle of a PCAN Channel (see TPCANHandle). 
Parameter 
The code of the value to be set (see TPCANParameter). 
Buffer 
The buffer containing the value to be set. 

The return value is 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 'Buffer'; it should point to a buffer of a type which is accepted by the parameter being configured. 
PCAN_ERROR_CAUTION: 
The configuration of a parameter failed due to a no more existing channel. The parameter has been reset on all existing channels. 
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 set. 
PCAN_ERROR_ILLOPERATION: 
An underlying process that is generated by a call to this method with the current parameters, is temporarily not allowed. The configuration in relation to the used TPCANParameter must be checked. 

Use the method SetValue to set configuration information or environment values of a PCAN Channel as parameters like the Message Filter and values like a custom entry in the log file of PCAN-Basic. 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 set 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 SetValue on the channel PCAN_NONEBUS to set (and activate) the path for the log file of a PCAN-Basic's debug session. 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 not needed to have an initialized PCAN channel for using the Log functionality. 

Python:  

# The path for the Log file is set.
# Note that this parameter is set using the
# default Channel (PCAN_NONEBUS)
#
strBuffer = "C:\Users\Admin\Desktop"
result = objPCAN.SetValue(PCAN_NONEBUS,PCAN_LOG_LOCATION,strBuffer)
if result != PCAN_ERROR_OK:
    # An error occurred, get a text describing the error and show it
    #
    result = objPCAN.GetErrorText(result)
    print result[1]
else:
    print "Log path was successfully set"
Copyright © 2017. PEAK-System Technik GmbH. All rights reserved.
Send feedback to this documentation