Lanner LEC-7230 Instrukcja Użytkownika Strona 20

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 24
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 19
20
Programming Watchdog Timer
Embedded and Industrial Computing
Appendix A
return nLeft ;
}
// Argument - function mapping
typedef struct
{
char *szCmd ;
int (*function) (int argc, char *argv[]) ;
} CMD2FUN ;
CMD2FUN c2f[] =
{
{“DIO_IN” , mDIO_IN
},
{“DIO_OUT , mDIO_OUT
},
{“PIO , mPIO
},
{“RunLED , mRunLED
},
{“AlarmLED , mAlarmLED
},
{“GPS_LED” , mGPS_LED
},
{“WirelessLED” , mWirelessLED },
{“CaseOpen , mCaseOpen },
{“CaseOpen_Clear,mCaseOpen_Clear},
{“Watchdog , mWatchDog
},
{“Sleep” , mSleep }
} ;
// Program start here
int main(int argc, char *argv[])
{
try
{
// The total argument allowed
int num = sizeof (c2f) / sizeof (c2f[0]) ;
// Too few argument
if (argc < 2)
RETMSG (-1, PARAMETER_HELP)
;
// Find the match argument and execute
the mapping function
for (int i = 0 ; i < num ; i++)
if (stricmp (argv[1], c2f[i].szCmd)
== 0)
return c2f[i].function
(argc, argv) ;
// No match argument
RETMSG (-1, Wrong Argument\n”) ;
}
catch (char *str)
{
// Output the error message
printf (“\n%s\n, str) ;
}
catch (...)
{
// Unknown exception
printf (“\nUnknown Exception\n”) ;
}
return -1 ;
}
Przeglądanie stron 19
1 2 ... 15 16 17 18 19 20 21 22 23 24

Komentarze do niniejszej Instrukcji

Brak uwag