Merge pull request #1076 from cmorty/pull/serialdump
Make EINVAL handling more robust and revert binary
This commit is contained in:
commit
cc3bcbefd4
Binary file not shown.
|
@ -164,13 +164,21 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
fprintf(stderr, "connecting to %s (%s)", device, speedname);
|
||||||
|
|
||||||
#ifdef O_SYNC
|
|
||||||
|
|
||||||
|
#ifndef O_SYNC
|
||||||
|
#define O_SYNC 0
|
||||||
|
#endif
|
||||||
|
#ifdef O_DIRECT
|
||||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC);
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT | O_SYNC);
|
||||||
if(fd < 0 && errno == EINVAL){ // O_SYNC not supported (e.g. raspberian)
|
/* Some systems do not support certain parameters (e.g. raspbian)
|
||||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_DIRECT);
|
* Just do some random testing. Not sure whether there is a better way
|
||||||
|
* of doing this. */
|
||||||
|
if(fd < 0 && errno == EINVAL){
|
||||||
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC );
|
fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY | O_SYNC);
|
||||||
#endif
|
#endif
|
||||||
if(fd < 0) {
|
if(fd < 0) {
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
|
Loading…
Reference in a new issue