DD2-monitor/serial/t.c

52 lines
1.1 KiB
C
Raw Normal View History

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