Add test for keypad.
[keypad.git] / test / keypad_test.c
blob0673c1cb481375ab2d0acfad0e3f3394655147ac
1 /*******************************************************************************
2 * File Name : keypad_test.c
3 *
4 * Author : Henry He
5 * Created Time : Fri 27 Nov 2009 09:55:20 AM CST
6 * Description :
7 ******************************************************************************/
10 /*******************************************************************************
11 * Desc : Includes Files
12 ******************************************************************************/
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <stdarg.h>
16 #include <unistd.h>
17 #include <string.h>
18 #include <fcntl.h>
19 #include <signal.h>
22 /*******************************************************************************
23 * Desc : Macro Definations
24 ******************************************************************************/
27 /*******************************************************************************
28 * Desc : Type Definations
29 ******************************************************************************/
32 /*******************************************************************************
33 * Desc : Global Variables
34 ******************************************************************************/
37 /*******************************************************************************
38 * Desc : File Variables
39 ******************************************************************************/
40 static int fdKeyPad = -1;
42 /******************************************************************************
43 * Func :
44 * Desc :
45 * Args :
46 * Outs :
47 ******************************************************************************/
48 void SignalHandler (int nSignal)
50 (void)nSignal;
51 close (fdKeyPad);
52 printf ("SignalHandler: exit\n");
53 exit (1);
56 /******************************************************************************
57 * Func :
58 * Desc :
59 * Args :
60 * Outs :
61 ******************************************************************************/
62 int main ( int argc, char *argv[] )
64 int nRetVal;
65 char cKey;
67 (void)argc;
68 (void)argv;
70 signal (SIGKILL, SignalHandler);
71 signal (SIGTERM, SignalHandler);
72 signal (SIGHUP, SignalHandler);
73 signal (SIGINT, SignalHandler);
75 #if 0
76 pthread_create ();
77 #endif
79 fdKeyPad = open ("/dev/keypad", O_RDONLY);
80 if (fdKeyPad < 0) {
81 printf ("can't open keypad\n");
82 return -1;
85 do {
86 nRetVal = read (fdKeyPad, &cKey, sizeof(cKey));
87 if (nRetVal < 0) {
88 break;
90 printf ("READ KEY %c\n", cKey);
91 } while (1);
93 return 0;
94 } /* ---------- end of function main ---------- */