GetErrorText(TPCANStatus, int)

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
GetErrorText(TPCANStatus, int)

Gets a descriptive text for an error code.

Syntax
def GetErrorText(
    self,
    Error,
    Language = 0)
Parameters 
Description 
Error 
A TPCANStatus error code. 
Language 
Indicates a "Primary language ID". 

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 'Buffer'; it should point to a char array, big enough to allocate the text for the given error code. 

[1]: The text corresponding to the given TPCANStatus code.

The "Primary language IDs" are codes used by Windows OS from Microsoft, to identify a human language. The PCAN-Basic API currently support the following languages:

Language 
Primary Language ID 
Neutral (System dependant) 
00h (0) 
English 
09h (9) 
German 
07h (7) 
French 
0Ch (12) 
Italian 
10h (16) 
Spanish 
0Ah (10) 

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 GetErrorText to get the description of an error. The language of the description's text will be in Spanish. 

Python:  

# Gets the description text for PCAN_ERROR_INITIALIZE using the language ID for Spanish
#
objPCAN = PCANBasic()
result = objPCAN.GetErrorText(PCAN_ERROR_INITIALIZE, 10)
if result[0] != PCAN_ERROR_OK:
    # An error occurred, show a message indicating it
    #
    print "Error when recovering Error-Code's description"
else:
    print result[1]

Primary Language ID 

 

Plain function Version: CAN_GetErrorText

Copyright © 2017. PEAK-System Technik GmbH. All rights reserved.
Send feedback to this documentation