comparison target-utils/loadagent/sertimeout.c @ 644:69acf5e0a21d

loadagent: implemented sertimeout calibration command
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 01 Mar 2020 23:49:31 +0000
parents
children 880c6d31e487
comparison
equal deleted inserted replaced
643:cd031e2501fa 644:69acf5e0a21d
1 /*
2 * Here we are going to implement a function for serial input with a timeout.
3 */
4
5 #include <stdlib.h>
6
7 serial_in_timeout(count)
8 unsigned count;
9 {
10 int c;
11
12 do
13 c = serial_in_poll();
14 while (c < 0 && --count);
15 return c;
16 }
17
18 void
19 cmd_sertimeout(argbulk)
20 char *argbulk;
21 {
22 char *argv[2];
23 int count, c;
24
25 if (parse_args(argbulk, 1, 1, argv, 0) < 0)
26 return;
27 count = atoi(argv[0]);
28 c = serial_in_timeout(count);
29 if (c >= 0)
30 printf("Got char\n");
31 else
32 printf("Timeout\n");
33 }