Bug fix: check file descriptor after opening serial device.
This commit is contained in:
parent
9a4ef8a909
commit
a59d1dc73b
3
util.c
3
util.c
|
@ -113,6 +113,9 @@ int open_serial(const char *device, int rate)
|
||||||
int fd = open(device, O_RDWR | O_NOCTTY);
|
int fd = open(device, O_RDWR | O_NOCTTY);
|
||||||
struct termios attr;
|
struct termios attr;
|
||||||
|
|
||||||
|
if (fd < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
tcgetattr(fd, &attr);
|
tcgetattr(fd, &attr);
|
||||||
cfmakeraw(&attr);
|
cfmakeraw(&attr);
|
||||||
cfsetispeed(&attr, rate);
|
cfsetispeed(&attr, rate);
|
||||||
|
|
Loading…
Reference in New Issue