/* * Experiments with the serial input * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #include #include #include #include #include #include //Used for UART #include //Used for UART #include #include //Used for UART #include "serial.h" int verbosity; /* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) { int serial_in, foo, count; char ligne[200]; if (2 != argc) { fprintf(stderr, "give me a device name, please.\n"); return 2; } serial_in = prepare_UART(argv[1], 9600); fprintf(stderr, "going to listen on %d\n", serial_in); for (count=0; count<10000; count++) { foo = getline_to(serial_in, ligne, 100, 0); fprintf(stderr, "getline #%d -> %d\n", count, foo); fprintf(stderr, "%s\n", ligne); foo = parseXvalue(ligne); fprintf(stderr, "parse -> %d\n", foo); if (foo>= 0) { printf("%d %d\n", count, foo); fflush(stdout); } } return 0; } /* ---------------------------------------------------------------- */