beautypg.com

Appendix e, Programming watchdog timer – Lanner LVC-5000(N4) User Manual

Page 38

background image

38

Programming Watchdog Timer

Embedded and Industrial Computing

Appendix E

“ 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)

G

P

I

O

_

O

U

T

(mPIO

, “DIO_OUT”

, PIO)

G

P

I

O

_

O

U

T

(mRunLED

, “RunLED”

, RunLED)

G

P

I

O

_

O

U

T

(mAlarmLED

, “AlarmLED”

, AlarmLED)

GPIO_OUT

(mGPS_

LED

, “GPS_LED”

,

GPS_LED)

G

P

I

O

_

O

U

T

(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 ;

}