serial : this patch need a real-life test

This commit is contained in:
tth 2018-12-13 18:43:49 +01:00
parent c1652b68e2
commit d75dba1954
2 changed files with 18 additions and 11 deletions

3
.gitignore vendored
View File

@ -1,7 +1,8 @@
a.out
*.o
fake-values
essai serial/t
essai
serial/t
doc/*.toc doc/*.log doc/*.aux doc/*.pdf

View File

@ -146,21 +146,27 @@ retval = retval < 0 ? -1 : retval;
switch (retval) {
case -1:
fprintf(stderr, "omg ?\n"); break;
fprintf(stderr, "omg ?\n");
byte = -1;
break;
case 0:
fprintf(stderr, "timeout\n"); break;
fprintf(stderr, "timeout\n");
byte = -99;
break;
default:
return -99;
if (retval==fd) {
read(fd, &byte, 1);
fprintf(stderr, "got 0x%02x\n", byte);
}
else {
fprintf(stderr, "%d bad fd ?\n", retval);
byte = -3;
}
break;
}
return -3;
return byte;
}
/* -------------------------------------------------------------------- */