root / serial-event.c
History | View | Annotate | Download (1.07 KB)
1 |
/* ser.c
|
---|---|
2 |
(C) 2004-5 Captain http://www.captain.at
|
3 |
|
4 |
Sends 3 characters (ABC) via the serial port (/dev/ttyS0) and reads
|
5 |
them back if they are returned from the PIC.
|
6 |
|
7 |
Used for testing the PIC-MMC test-board
|
8 |
http://www.captain.at/electronic-index.php
|
9 |
|
10 |
*/
|
11 |
#include <stdio.h> /* Standard input/output definitions */ |
12 |
#include <string.h> /* String function definitions */ |
13 |
#include <unistd.h> /* UNIX standard function definitions */ |
14 |
#include <fcntl.h> /* File control definitions */ |
15 |
#include <errno.h> /* Error number definitions */ |
16 |
#include <termios.h> /* POSIX terminal control definitions */ |
17 |
#include <gdk/gdkkeysyms.h> |
18 |
#include <glib/gprintf.h> |
19 |
|
20 |
static int flagserial; |
21 |
|
22 |
|
23 |
extern int wait_time; |
24 |
|
25 |
int check_for_user_input ()
|
26 |
{ |
27 |
int fd, i = 0, event = 0; |
28 |
char string[10] = ""; |
29 |
|
30 |
|
31 |
for (i = 0; i < wait_time / 100; i++) |
32 |
{ |
33 |
int n;
|
34 |
strcpy (string, "");
|
35 |
usleep(100000);
|
36 |
if (flagserial==1) |
37 |
{ |
38 |
flagserial=0;
|
39 |
return (event = 1); |
40 |
} |
41 |
} |
42 |
return event;
|
43 |
} |
44 |
|
45 |
int check ()
|
46 |
{ |
47 |
g_print ("wait_time is : %d\n",wait_time);
|
48 |
flagserial=1;
|
49 |
return 0; |
50 |
} |
51 |
|
52 |
|