Open Core Interface - MLPI
MLPI-MotionLogicProgrammingInterface(mlpi4LabVIEW)  1.26.2
Watchdog handling
Collaboration diagram for Watchdog handling:

Functions

MLPIRESULT mlpiWatchdogSetup (const MLPIHANDLE connection, ULONG timeout, MlpiWatchdogAction action)
 
MLPIRESULT mlpiWatchdogStart (const MLPIHANDLE connection)
 
MLPIRESULT mlpiWatchdogStop (const MLPIHANDLE connection)
 
MLPIRESULT mlpiWatchdogReset (const MLPIHANDLE connection)
 
MLPIRESULT mlpiWatchdogGetState (const MLPIHANDLE connection, MlpiWatchdogState *state)
 

Detailed Description

The following functions are used for initializing and using the watchdogs from the client application.

Function Documentation

MLPIRESULT mlpiWatchdogSetup ( const MLPIHANDLE  connection,
ULONG  timeout,
MlpiWatchdogAction  action 
)

This function initializes or changes the watchdog functionality.

Parameters
[in]connectionHandle for multiple connections.
[in]timeoutThis is the timeout of the watchdog in ms. The timeout is checked every millisecond.
[in]actionThis is the action that will be taken in the case that the watchdog expires.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // initialization of the watchdog (2 seconds).
2 // configured so that the watchdog will fire a warning if it doesn't get triggered in time.
3 MLPIRESULT result = mlpiWatchdogSetup(connection, 2000, MLPI_WATCHDOG_WARNING);
4 if (MLPI_FAILED(result)) {
5  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
6  return;
7 }
8 
9 // starting the Watchdog
10 result = mlpiWatchdogStart(connection);
11 if (MLPI_FAILED(result)) {
12  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
13 }
MLPIRESULT mlpiWatchdogStart ( const MLPIHANDLE  connection)

This function starts the watchdog supervision.

Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
See example for mlpiWatchdogSetup.
MLPIRESULT mlpiWatchdogStop ( const MLPIHANDLE  connection)

This function stops the watchdog supervision.

Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // stop the Watchdog, calls to mlpiWatchdogReset() no longer necessary
2 MLPIRESULT result = mlpiWatchdogStop(connection);
3 if (MLPI_FAILED(result)) {
4  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
5 }
MLPIRESULT mlpiWatchdogReset ( const MLPIHANDLE  connection)

This function resets the watchdog. Has to be called in an interval which is shorter than the timeout that has been specified in Setup method.

Parameters
[in]connectionHandle for multiple connections.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 while(1)
2 {
3  // you may want to do some work here...
4  Sleep(1000);
5 
6  // reset watchdog to prevent watchdog from triggering, do this every loop
7  MLPIRESULT result = mlpiWatchdogReset(connection);
8  if (MLPI_FAILED(result)) {
9  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
10  }
11 }
MLPIRESULT mlpiWatchdogGetState ( const MLPIHANDLE  connection,
MlpiWatchdogState state 
)

This function will return the current state of the watchdog. Once the watchdog fired, the function will return that state until it is reset using mlpiWatchdogReset.

Parameters
[in]connectionHandle for multiple connections.
[out]statePointer to where the state should be stored.
Returns
Return value indicating success (>=0) or error (<0).
Example:
1 // print current state of watchdog
2 MlpiWatchdogState state;
3 MLPIRESULT result = mlpiWatchdogGetState(connection, &state);
4 if (MLPI_FAILED(result)) {
5  printf("\ncall of MLPI function failed with 0x%08x!", (unsigned)result);
6 } else {
7  switch(state)
8  {
9  case MLPI_WATCHDOG_DISABLED:
10  printf("\nWATCHDOG_DISABLED");
11  break;
12  case MLPI_WATCHDOG_ENABLED:
13  printf("\nWATCHDOG_ENABLED");
14  break;
15  case MLPI_WATCHDOG_TIMEOUT:
16  printf("\nWATCHDOG_TIMEOUT");
17  break;
18  }
19 }