CAN_GetErrorText

PCAN-Basic

PCAN-Basic Documentation
Home
PreviousUpNext
CAN_GetErrorText

Returns a descriptive text for an error code.

Syntax
TPCANStatus __stdcall CAN_GetErrorText(
        TPCANStatus Error,
        WORD Language,
        LPSTR Buffer
);
Parameters 
Description 
Error 
A TPCANStatus error code. 
Language 
Indicates a "Primary language ID". 
Buffer 
A buffer for a null-terminated char array. 

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 function are invalid. Check the parameter 'Buffer'; it should point to a char array, big enough to allocate the text for the given error 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 (English) 
00h (0) 
English 
09h (9) 
German 
07h (7) 
French 
0Ch (12) 
Italian 
10h (16) 
Spanish 
0Ah (10) 

Note: If the buffer is to small for the resulting text, the error PCAN_ERROR_ILLPARAMVAL is returned. Even when only short texts are being currently returned, a text within this function can have a maximum of 255 characters. For this reason it is recommended to use a buffer with a length of at least 256 bytes.

The following example shows the use of CAN_GetErrorText to get the description of an error. The language of the description's text will be the same used by the operating system. 

C++:  

TPCANStatus result;
char strMsg[256];

// Gets the description text for PCAN_ERROR_INITIALIZE using the Neutral language
//
result = CAN_GetErrorText(PCAN_ERROR_INITIALIZE, 0, strMsg);
if(result != PCAN_ERROR_OK)
    // An error occurred, get a text describing the error and show it
    //
    MessageBox("Error when recovering Error-Code's description");
else
    MessageBox(strMsg);

Primary Language ID 

 

Class-method Version: GetErrorText

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