DD2-monitor/serial/t.c

30 lines
503 B
C
Raw Normal View History

2018-12-13 02:06:18 +11:00
#include <stdio.h>
2018-12-13 08:26:54 +11:00
#include <time.h>
2018-12-13 02:06:18 +11:00
#include "serial.h"
int main (int argc, char *argv[])
{
int serial_in;
2018-12-13 06:07:49 +11:00
int byte, foo, to;
2018-12-13 02:06:18 +11:00
serial_in = prepare_UART("/dev/ttyS0", 9600);
fprintf(stderr, "prepare uart -> %d\n", serial_in);
for (foo=0; foo<20; foo++) {
2018-12-13 06:07:49 +11:00
to = (foo+1) * 666;
byte = getbyte_to(serial_in, to);
if (byte < 0) {
fprintf(stderr, "get byte : err is %d\n", byte);
}
2018-12-13 08:26:54 +11:00
// XXX else {
printf("%9ld %6d %6d %02x\n",
time(NULL), foo, to, byte);
// XXX }
2018-12-13 02:06:18 +11:00
}
return 0;
}