source: umon/main/glib/pollconsole.c @ 87db514

Last change on this file since 87db514 was 87db514, checked in by Amar Takhar <amar@…>, on 04/16/15 at 19:26:21

Initial commit of the umon repository.

Prior to this three changes were made:

  • Remove umon_ prefix from parent directories.
  • Collapse main/target/ into main/
  • Remove ports/template/flashtest.scr.ucon script.
  • Property mode set to 100755
File size: 839 bytes
Line 
1#include "config.h"
2#include <ctype.h>
3#include "ether.h"
4#include "genlib.h"
5#include "stddefs.h"
6#include "timer.h"
7
8/* pollConsole():
9 * Common function used to query the console port with a message.
10 * If after about a 2-second period (or the time specified by POLLTIMEOUT),
11 * there is no response from the console, then return 0; else return
12 * the character that was received.
13 */
14int
15pollConsole(char *msg)
16{
17        char    *env;
18        int             pollval, msec;
19        struct elapsed_tmr tmr;
20
21        env = getenv("POLLTIMEOUT");
22        if (env)
23                msec = strtol(env,0,0);
24        else
25                msec = 2000;
26
27        pollval = 0;
28        printf("%s",msg);
29        startElapsedTimer(&tmr,msec);
30        while(!msecElapsed(&tmr)) {
31                if (gotachar()) {
32                        while(gotachar())
33                                pollval = getchar();
34                        break;
35                }
36                pollethernet();
37        }
38        putstr("\r\n");
39       
40        if (ELAPSED_TIMEOUT(&tmr))
41                return(0);
42
43        return(pollval);
44}
Note: See TracBrowser for help on using the repository browser.