workaround the infamous select() bug : first milestone, demo code is coming

This commit is contained in:
2018-12-29 17:07:23 +01:00
parent 560edb14e8
commit 6aa2a26bec
7 changed files with 65 additions and 18 deletions

View File

@@ -17,10 +17,12 @@
int verbosity;
/* ---------------------------------------------------------------- */
/* ---------------------------------------------------------------- */
int main (int argc, char *argv[])
{
int serial_in, foo;
int serial_in, foo, count;
char ligne[200];
if (2 != argc) {
fprintf(stderr, "give me a device name, please.\n");
@@ -31,17 +33,15 @@ serial_in = prepare_UART(argv[1], 9600);
fprintf(stderr, "going to listen on %d\n", serial_in);
for (;;) {
foo = getbyte_to(serial_in, 50000);
if (foo < 0) {
fprintf(stderr, "get byte : got %d, err is %d\n",
foo, errno);
}
else {
printf("%9ld $%02x ", time(NULL), foo);
if (isprint(foo)) putchar(foo);
puts("");
if ('\n'==foo) puts("");
for (count=0; count<10000; count++) {
foo = getline_to(serial_in, ligne, 100, 0);
fprintf(stderr, "getline #%d -> %d\n", count, foo);
fprintf(stderr, "%s\n", ligne);
foo = parseXvalue(ligne);
fprintf(stderr, "parse -> %d\n", foo);
if (foo>= 0) {
printf("%d %d\n", count, foo);
fflush(stdout);
}
}