blocking read is not blocking

This commit is contained in:
2018-12-20 11:57:23 +01:00
parent 8a34fed6af
commit bb10042aae
6 changed files with 115 additions and 26 deletions

View File

@@ -1,28 +1,36 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "serial.h"
int verbosity;
int main (int argc, char *argv[])
{
int serial_in;
int byte, foo, to;
int serial_in;
int byte;
serial_in = prepare_UART("/dev/ttyS0", 9600);
serial_in = prepare_UART("/dev/ttyACM0", 9600);
fprintf(stderr, "prepare uart -> %d\n", serial_in);
for (foo=0; foo<20; foo++) {
to = (foo+1) * 666;
byte = getbyte_to(serial_in, to);
if (serial_in < 0) {
exit(1);
}
for (;;) {
byte = getbyte(serial_in);
if (byte < 0) {
fprintf(stderr, "get byte : err is %d\n", byte);
}
// XXX else {
printf("%9ld %6d %6d %02x\n",
time(NULL), foo, to, byte);
// XXX }
else {
printf("%9ld %02x/%d\n",
time(NULL), byte, byte);
}
}
return 0;