Laelaps  2.3.5
RoadNarrows Robotics Small Outdoor Mobile Robot Project
laelaps_diag

Macros

#define APP_EC_OK   0
 success exit code
 
#define APP_EC_ARGS   2
 command-line options/arguments error exit code
 
#define APP_EC_EXEC   4
 execution exit code
 

Functions

static DiagStats prelims ()
 
static void mainInit (int argc, char *argv[])
 Main initialization. More...
 
int main (int argc, char *argv[])
 Main. More...
 

Variables

static char * Argv0
 the command
 
static bool_t OptsMotion = false
 motion option
 
static bool_t OptsAnyKey = false
 user presses anykey to stop option
 
static const char * DiagnosticsAvail []
 Available diagnostics. More...
 
static vector< string > DiagnosticsToRun
 diagnostics to run
 
static OptsPgmInfo_T PgmInfo
 Program information. More...
 
static OptsInfo_T OptsInfo []
 Command line options information.
 
LaeDesc RobotDesc
 
LaeI2C I2CBus
 
LaeI2CMux I2CMux (I2CBus)
 
LaeWd WatchDog (I2CBus)
 

Detailed Description

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Main.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Returns
Returns 0 on succes, non-zero on failure.

Definition at line 380 of file laelaps_diag.cxx.

References APP_EC_OK, DiagnosticsToRun, mainInit(), OptsAnyKey, and OptsMotion.

381 {
382  string strDiag;
383  DiagStats statsGrandTotal;
384 
385  mainInit(argc, argv);
386 
387  setTags(LOG_IN_COLOR());
388 
389  statsGrandTotal = prelims();
390 
391  for(size_t i = 0; i < DiagnosticsToRun.size(); ++i)
392  {
393  if( statsGrandTotal.fatal )
394  {
395  break;
396  }
397 
398  strDiag = DiagnosticsToRun[i];
399 
400  if( strDiag == "product" )
401  {
402  statsGrandTotal += runProductDiagnostics();
403  }
404  else if( strDiag == "cpu" )
405  {
406  statsGrandTotal += runCpuDiagnostics();
407  }
408  else if( strDiag == "motors" )
409  {
410  statsGrandTotal += runMotorsDiagnostics(OptsMotion);
411  }
412  else if( strDiag == "cam" )
413  {
414  statsGrandTotal += runCamDiagnostics();
415  }
416  else if( strDiag == "tof" )
417  {
418  statsGrandTotal += runToFDiagnostics(OptsAnyKey);
419  }
420  else if( strDiag == "imu" )
421  {
422  statsGrandTotal += runImuDiagnostics(OptsAnyKey);
423  }
424  else if( strDiag == "watchdog" )
425  {
426  statsGrandTotal += runWatchDogDiagnostics();
427  }
428  else if( strDiag == "batt" )
429  {
430  statsGrandTotal += runBatteryDiagnostics(OptsAnyKey);
431  }
432  }
433 
434  printGrandTotals(statsGrandTotal);
435 
436  return APP_EC_OK;
437 }
#define APP_EC_OK
success exit code
static bool_t OptsAnyKey
user presses anykey to stop option
Simple diagnostics statistics class.
Definition: laelaps_diag.h:106
static bool_t OptsMotion
motion option
static void mainInit(int argc, char *argv[])
Main initialization.
static vector< string > DiagnosticsToRun
diagnostics to run
static void mainInit ( int  argc,
char *  argv[] 
)
static

Main initialization.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exits:
Program terminates on conversion error.

Definition at line 299 of file laelaps_diag.cxx.

References APP_EC_ARGS, Argv0, DiagnosticsAvail, DiagnosticsToRun, OptsInfo, PgmInfo, and PkgInfo.

Referenced by main().

300 {
301  string strArg;
302  bool bFound;
303 
304  // name of this process
305  Argv0 = basename(argv[0]);
306 
307  // parse input options
308  argv = OptsGet(Argv0, &PkgInfo, &PgmInfo, OptsInfo, true, &argc, argv);
309 
310  if( argc == 0 )
311  {
312  fprintf(stderr, "%s: Error: No diagnostics specified.\n", Argv0);
313  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
314  exit(APP_EC_ARGS);
315  }
316 
317  for(int i = 0; i < argc; ++i)
318  {
319 
320  strArg = argv[i];
321 
322  if( strArg == "all" )
323  {
324  DiagnosticsToRun.clear();
325  for(size_t j = 0; j < arraysize(DiagnosticsAvail); ++j)
326  {
327  DiagnosticsToRun.push_back(DiagnosticsAvail[j]);
328  }
329  break;
330  }
331 
332  bFound = false;
333 
334  for(size_t j = 0; j < arraysize(DiagnosticsAvail); ++j)
335  {
336  if( strArg == DiagnosticsAvail[j] )
337  {
338  DiagnosticsToRun.push_back(DiagnosticsAvail[j]);
339  bFound = true;
340  break;
341  }
342  }
343 
344  if( !bFound )
345  {
346  fprintf(stderr, "%s: Warning: Unknown diganostic %s - ignoring.\n",
347  Argv0, strArg.c_str());
348  }
349  }
350 
351  if( DiagnosticsToRun.empty() )
352  {
353  fprintf(stderr, "%s: Error: No valid diagnostics to run.\n", Argv0);
354  fprintf(stderr, "Try '%s --help' for more information.\n", Argv0);
355  exit(APP_EC_ARGS);
356  }
357 }
#define APP_EC_ARGS
command-line options/arguments error exit code
static char * Argv0
the command
static OptsPgmInfo_T PgmInfo
Program information.
static const PkgInfo_T PkgInfo
Definition: version.h:45
static OptsInfo_T OptsInfo[]
Command line options information.
static const char * DiagnosticsAvail[]
Available diagnostics.
static vector< string > DiagnosticsToRun
diagnostics to run

Variable Documentation

const char* DiagnosticsAvail[]
static
Initial value:
=
{
"product", "cpu", "motors", "watchdog", "tof", "imu", "cam", "batt"
}

Available diagnostics.

Definition at line 103 of file laelaps_diag.cxx.

Referenced by mainInit().

OptsPgmInfo_T PgmInfo
static
Initial value:
=
{
"DIAG [DIAG ...]",
"Run Laelaps diagnostics.",
"The %P command executes Laelaps subsystem diagnostics. "
"The Laelaps embedded software interfaces are used to test the subsystems."
"\n\n"
"DIAG: Diagnostic to run. One of:\n"
" all - Run all dignostics.\n"
" batt - Run battery dignostics.\n"
" cam - Run camera diagnotics.\n"
" cpu - Run main CPU diagnotics.\n"
" imu - Run Inertia Measurement Unit diagnostics.\n"
" motors - Run motors diagnotics.\n"
" product - Run Laelaps product diagnotics.\n"
" tof - Run time-of-flight sensors diagnostics.\n"
" watchdog - Run Arduino watchdog sub-processor diagnostics.\n\n"
"The ROS node laelaps_control cannot be running while using this tool.",
NULL
}

Program information.

Definition at line 113 of file laelaps_diag.cxx.

Referenced by mainInit().