DD2-monitor/serial/t.c

38 lines
498 B
C
Raw Normal View History

2018-12-12 16:06:18 +01:00
#include <stdio.h>
2018-12-20 11:57:23 +01:00
#include <stdlib.h>
2018-12-12 22:26:54 +01:00
#include <time.h>
2018-12-12 16:06:18 +01:00
#include "serial.h"
2018-12-20 11:57:23 +01:00
int verbosity;
2018-12-12 16:06:18 +01:00
int main (int argc, char *argv[])
{
2018-12-20 11:57:23 +01:00
int serial_in;
int byte;
2018-12-12 16:06:18 +01:00
2018-12-20 11:57:23 +01:00
serial_in = prepare_UART("/dev/ttyACM0", 9600);
2018-12-12 16:06:18 +01:00
fprintf(stderr, "prepare uart -> %d\n", serial_in);
2018-12-20 11:57:23 +01:00
if (serial_in < 0) {
exit(1);
}
for (;;) {
byte = getbyte(serial_in);
2018-12-12 20:07:49 +01:00
if (byte < 0) {
fprintf(stderr, "get byte : err is %d\n", byte);
}
2018-12-20 11:57:23 +01:00
else {
printf("%9ld %02x/%d\n",
time(NULL), byte, byte);
}
2018-12-12 16:06:18 +01:00
}
return 0;
}