“ Watchdog
Set
Watchdog timer.\n”\
“
CaseOpen Check case opened state.\n”\
“
CaseOpen_Clear Clear case open state.\n”\
“ port_number The port number.\n”\
“ value 1 for on and 0 for off.\n”\
“ seconds
The
watchdog count down seconds. 0 for disable.\n”\
“ milliseconds Milliseconds to delay\n”
#define RETMSG(a,b) {printf (b) ; return a;}
#define CHECK_ARGC(a) {if (argc != a) throw PARAMETER_HELP ;}
// Translate Hex string to a long value
LONG Hex2Long (char *str)
{
LONG nLong ;
if (scanf (str, “%x”, &nLong) != 1)
throw “Error parsing parameter\n” ;
return nLong ;
}
// Make sure the argument is numeric
void CheckNumeric (char *szBuf)
{
int nLen = strlen (szBuf) ;
for (int i = 0 ; i < nLen ; i++)
if (!strchr (“01234567890ABCDEFabcdef”, szBuf[i]) )
throw “Wrong argument\n” ;
}
// Common GPIO output function definition
#define GPIO_OUT(a,b,c)
\
int a (int argc, char *argv[])
\
{
\
CHECK_ARGC (4) ;
\
CheckNumeric (argv[2]) ;
\
CheckNumeric (argv[3]) ;
\
\
int nPort = atoi (argv[2]) ; \
int nValue = atoi (argv[3]) ;
\
\
c (nPort, nValue) ;
\
\
printf (b “ #%d = %d\n”, nPort, nValue) ;
\
\
return 0 ;
\
}
// Function generate by common function definition
GPIO_OUT (mDIO_OUT
, “DIO_OUT”
,
Write_DIO)
GPIO_OUT (mPIO
, “DIO_OUT”
, PIO)
GPIO_OUT (mRunLED
, “RunLED”
,
RunLED)
GPIO_OUT (mAlarmLED
, “AlarmLED”
,
AlarmLED)
GPIO_OUT (mGPS_LED
, “GPS_LED”
,
GPS_LED)
GPIO_OUT (mWirelessLED
, “WirelessLED” ,
WirelessLED)
// Check case open
int mCaseOpen (int argc, char* argv[])
{
CHECK_ARGC (2) ;
BOOL bOpen = CaseOpen () ;
printf (“Case is %s\n”, bOpen ? “Open” : “Close”) ;
return bOpen ;
}