DD2-monitor/serial/t.c

52 lines
1.1 KiB
C
Raw Normal View History

2018-12-29 22:09:34 +11:00
/*
* Experiments with the serial input
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
2018-12-13 02:06:18 +11:00
#include <stdio.h>
2018-12-20 21:57:23 +11:00
#include <stdlib.h>
2018-12-29 19:45:22 +11:00
#include <strings.h>
#include <ctype.h>
2018-12-13 08:26:54 +11:00
#include <time.h>
2018-12-22 03:53:17 +11:00
#include <unistd.h> //Used for UART
#include <fcntl.h> //Used for UART
#include <errno.h>
2018-12-29 19:45:22 +11:00
#include <termios.h> //Used for UART
2018-12-13 02:06:18 +11:00
#include "serial.h"
2018-12-20 21:57:23 +11:00
int verbosity;
/* ---------------------------------------------------------------- */
2018-12-29 22:09:34 +11:00
/* ---------------------------------------------------------------- */
2018-12-13 02:06:18 +11:00
int main (int argc, char *argv[])
{
int serial_in, foo, count;
char ligne[200];
2018-12-13 02:06:18 +11:00
2018-12-22 03:53:17 +11:00
if (2 != argc) {
2018-12-29 12:43:12 +11:00
fprintf(stderr, "give me a device name, please.\n");
2018-12-22 03:53:17 +11:00
return 2;
}
2018-12-29 22:09:34 +11:00
serial_in = prepare_UART(argv[1], 9600);
2018-12-29 19:45:22 +11:00
2018-12-29 22:09:34 +11:00
fprintf(stderr, "going to listen on %d\n", serial_in);
2018-12-29 19:45:22 +11:00
2019-01-01 03:19:52 +11:00
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);
2018-12-30 03:45:31 +11:00
foo = parseXvalue(ligne, 'X');
2019-01-01 03:19:52 +11:00
// fprintf(stderr, "parse -> %d\n", foo);
if (foo>= 0) {
printf("%d %d\n", count, foo);
fflush(stdout);
2018-12-20 21:57:23 +11:00
}
2018-12-13 02:06:18 +11:00
}
return 0;
}
2018-12-22 03:53:17 +11:00
2018-12-29 22:09:34 +11:00
/* ---------------------------------------------------------------- */