Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpi4LabVIEW)  1.26.2
Diagnosis system
Collaboration diagram for Diagnosis system:

Functions

MLPIRESULT mlpiSystemGetDisplayedDiagnosis (const MLPIHANDLE connection, MlpiDiagnosis *diagnosis)
 
MLPIRESULT mlpiSystemSetDiagnosis (const MLPIHANDLE connection, const MlpiDiagnosisCategory category, const USHORT number, const WCHAR16 *diagnosisText=0)
 
MLPIRESULT mlpiSystemGetNewestDiagnosisIndex (const MLPIHANDLE connection, ULONG *index)
 
MLPIRESULT mlpiSystemGetOldestDiagnosisIndex (const MLPIHANDLE connection, ULONG *index)
 
MLPIRESULT mlpiSystemGetDiagnosisLog (const MLPIHANDLE connection, const ULONG index, MlpiDiagnosis *diagnosisLog, const ULONG numElements, ULONG *numElementsRet)
 
MLPIRESULT mlpiSystemConvertDiagnosisNumberToText (const MLPIHANDLE connection, const ULONG diagnosisNumber, WCHAR16 *diagnosisText, const ULONG numElements)
 
MLPIRESULT mlpiSystemSetBootLed (const MLPIHANDLE connection, const MlpiLedPattern pattern, const LONG count=-1)
 
MLPIRESULT mlpiSystemClearBootLed (const MLPIHANDLE connection)
 

Detailed Description

The following functions provide access to the internal diagnosis logbook on the target device. For a detailed description of all error codes and diagnosis numbers, please have a look to the diagnosis help of the device you are connected too.

Function Documentation

MLPIRESULT mlpiSystemGetDisplayedDiagnosis ( const MLPIHANDLE  connection,
MlpiDiagnosis diagnosis 
)

This function reads the displayed diagnostic message of the device. The displayed diagnosis is the diagnosis with the highest severity of all currently active diagnoses. This means, that the displayed diagnostic message can differ from the latest or last inserted diagnostic message.

Parameters
[in]connectionHandle for multiple connections.
[out]diagnosisPointer to structure where the diagnosis will be stored.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the displayed diagnostic message of the device.
2 MlpiDiagnosis diagnosis;
3 memset(&diagnosis, 0, sizeof(diagnosis));
4 MLPIRESULT result = mlpiSystemGetDisplayedDiagnosis(connection, &diagnosis);
5 
6 if (MLPI_FAILED(result)) {
7  printf("\ncall of MLPI function failed with 0x%08x!", result);
8 } else {
9  printf("\n0x%08X %s", diagnosis.number, W2A16(diagnosis.text));
10 }
MLPIRESULT mlpiSystemSetDiagnosis ( const MLPIHANDLE  connection,
const MlpiDiagnosisCategory  category,
const USHORT  number,
const WCHAR16 diagnosisText = 0 
)

This function writes a diagnosis with message to the diagnosis system of the device. The diagnostic group is set to 0x3F automatically.

Parameters
[in]connectionHandle for multiple connections.
[in]categoryDiagnosis category (MlpiDiagnosisCategory).
[in]numberUser specific diagnosis number.
[in]diagnosisTextDiagnosis text.
Note
The maximum length of a diagnosis text is 60 characters.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Write a diagnosis with message to the diagnosis system of the device.
2 USHORT number = 1;
3 WCHAR16 diagnosisText[] = L"This is a new diagnosis";
4 MLPIRESULT result = mlpiSystemSetDiagnosis(connection, MLPI_DIAGNOSIS_ERROR_NONFATAL, number, diagnosisText);
MLPIRESULT mlpiSystemGetNewestDiagnosisIndex ( const MLPIHANDLE  connection,
ULONG index 
)

Each new diagnosis in the diagnosis logbook gets a unique incremented diagnosis index. This function returns the index of the latest and therefore most recently inserted diagnosis. This index can be used as a parameter using the function mlpiSystemGetDiagnosisLog to read the complete logbook of the newest diagnostic messages.

Parameters
[in]connectionHandle for multiple connections.
[out]indexPointer to variable where the index of the newest diagnosis will be stored.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the index of the latest diagnosis in the diagnosis logbook of the device.
2 ULONG index = 0;
3 MLPIRESULT result = mlpiSystemGetNewestDiagnosisIndex(connection, &index);
MLPIRESULT mlpiSystemGetOldestDiagnosisIndex ( const MLPIHANDLE  connection,
ULONG index 
)

As the device is limited in memory resources, it is not possible to hold all diagnostic messages in the logbook from the start of power up. Because of that, older diagnostic messages are first swapped to disk and then discarded. Use this function to get the index of the oldest diagnostic message that is still in memory and can be returned by the function mlpiSystemGetDiagnosisLog.

Parameters
[in]connectionHandle for multiple connections.
[out]indexPointer to variable where the index of oldest diagnosis will be stored.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the index of oldest diagnosis in the diagnosis logbook of the device.
2 ULONG index = 0;
3 MLPIRESULT result = mlpiSystemGetOldestDiagnosisIndex(connection, &index);
MLPIRESULT mlpiSystemGetDiagnosisLog ( const MLPIHANDLE  connection,
const ULONG  index,
MlpiDiagnosis diagnosisLog,
const ULONG  numElements,
ULONG numElementsRet 
)

This function reads the device diagnosis log. The function returns an array of diagnostic messages starting from newer to older diagnostic messages. Each diagnosis in the diagnosis logbook has a unique incrementing diagnosis index. You need to specify from which index you want to start reading the diagnosis logbook. To get the index of the latest and thus most recently inserted diagnosis, you can use the function mlpiSystemGetNewestDiagnosisIndex. As the device is limited in memory resources, it is not possible to hold all diagnostic messages in the logbook from the start of power up. Because of that, older diagnostic messages are first swapped to disk and then discarded. Use the function mlpiSystemGetOldestDiagnosisIndex to get the oldest available diagnosis to read. Diagnostic messages which are not located between the oldest and newest diagnosis index can no longer be read by this function. This function will therefore return the number of diagnoses that have actually been read. This function will not return an error if the number of diagnoses you want to read is larger than the number of diagnoses that are available.

Parameters
[in]connectionHandle for multiple connections.
[in]indexIndex of the first diagnosis index to start reading.
[out]diagnosisLogPointer to an array of structure where the diagnosis will be stored.
[in]numElementsNumber of MlpiDiagnosis elements available in 'diagnosisLog' for reading.
[out]numElementsRetNumber of elements used.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the complete diagnosis log of the device.
2 MlpiDiagnosis diagnosisLog[1000];
3 ULONG numElementsRet = 0;
4 ULONG indexNewest = 0;
5 ULONG indexOldest = 0;
6 memset(diagnosisLog, 0, sizeof(diagnosisLog));
7 
8 mlpiSystemGetOldestDiagnosisIndex(connection, &indexOldest);
9 mlpiSystemGetNewestDiagnosisIndex(connection, &indexNewest);
10 mlpiSystemGetDiagnosisLog(connection, indexNewest, diagnosisLog, min(indexNewest-indexOldest,_countof(diagnosisLog)), &numElementsRet);
11 
12 for (ULONG i=0; i<numElementsRet; i++){
13  printf("\n%i 0x%X %s", diagnosisLog[i].index, diagnosisLog[i].number, W2A16(diagnosisLog[i].text));
14 }
MLPIRESULT mlpiSystemConvertDiagnosisNumberToText ( const MLPIHANDLE  connection,
const ULONG  diagnosisNumber,
WCHAR16 diagnosisText,
const ULONG  numElements 
)

This function tries to retrieve a textual description for a given diagnosis number. Please note that this is not possible for every diagnosis number that is returned from the system. This includes user-specific diagnosis numbers or diagnosis numbers which represent a group of error conditions. In case no match was found, the string "No entry found in data base" is returned.

Parameters
[in]connectionHandle for multiple connections.
[in]diagnosisNumberDiagnosis number.
[out]diagnosisTextString where the diagnosis text will be stored.
[in]numElementsNumber of WCHAR16 elements available in 'diagnosisText' for reading.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Read the textual description for a diagnosis number.
2 ULONG diagnosisNumber = 0xF02D1001;
3 WCHAR16 diagnosisText[256] = L"";
4 MLPIRESULT result = mlpiSystemConvertDiagnosisNumberToText(connection, diagnosisNumber, diagnosisText, _countof(diagnosisText));
5 
6 if (MLPI_FAILED(result)) {
7  printf("\ncall of MLPI function failed with 0x%08x!", result);
8 } else {
9  printf("\n%08X means: %s", diagnosisNumber, W2A16(diagnosisText));
10 }
MLPIRESULT mlpiSystemSetBootLed ( const MLPIHANDLE  connection,
const MlpiLedPattern  pattern,
const LONG  count = -1 
)

This function switch on the boot LED 'BT' (if available) regarding the selected MlpiLedPattern pattern.

Note
Because the system use the boot LED 'BT' for signal boot status, the function will return an error if system is still booting.
  • MLPI_E_NOTINITIALIZED: Boot end not achieved yet.
  • MLPI_E_STARTERROR: Boot finished with error(s), reboot may be required.
Parameters
[in]connectionHandle for multiple connections.
[in]patternLED pattern.
[in]countCount of repeat pattern. Use "-1" for repeat infinite.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Switch on the boot LED 'BT' permanently.
2 MLPIRESULT result = mlpiSystemSetBootLed(connection, MLPI_LED_PATTERN_GREEN);
3 
4 if (MLPI_FAILED(result)) {
5  printf("\ncall of MLPI function failed with 0x%08x!", result);
6 }
MLPIRESULT mlpiSystemClearBootLed ( const MLPIHANDLE  connection)

This function switch off the boot LED 'BT' (if available).

Note
Because the system use the boot LED 'BT' for signal boot status, the function will return an error if system is still booting.
  • MLPI_E_NOTINITIALIZED: Boot end not achieved yet.
  • MLPI_E_STARTERROR: Boot finished with error(s), reboot may be required.
Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // Switch off the boot LED 'BT'.
2 MLPIRESULT result = mlpiSystemClearBootLed(connection);
3 
4 if (MLPI_FAILED(result)) {
5  printf("\ncall of MLPI function failed with 0x%08x!", result);
6 }