52 lines
1.1 KiB
C
52 lines
1.1 KiB
C
/*
|
|
* Experiments with the serial input
|
|
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <strings.h>
|
|
#include <ctype.h>
|
|
#include <time.h>
|
|
#include <unistd.h> //Used for UART
|
|
#include <fcntl.h> //Used for UART
|
|
#include <errno.h>
|
|
#include <termios.h> //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<100000; 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, 'X');
|
|
// fprintf(stderr, "parse -> %d\n", foo);
|
|
if (foo>= 0) {
|
|
printf("%d %d\n", count, foo);
|
|
fflush(stdout);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|