Commit 6b9486bd authored by Mart Lubbers's avatar Mart Lubbers
Browse files

test

parent 2fc04768
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#endif #endif
#define INITIAL_BUFFERSIZE 2 #define INITIAL_BUFFERSIZE 2
#define DEVICE_TIMEOUT {0, 0}
#define die(s) {perror(s);exit(EXIT_FAILURE);} #define die(s) {perror(s);exit(EXIT_FAILURE);}
...@@ -102,8 +101,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity, ...@@ -102,8 +101,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
debug("ttyopen"); debug("ttyopen");
struct termios tio; struct termios tio;
char *cs_fn = cleanStringToCString(fn); char *cs_fn = cleanStringToCString(fn);
*fd = open(cs_fn, O_RDWR | O_NOCTTY); *fd = open(cs_fn, O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
*status = 0; *status = 0;
fcntl(*fd, F_SETFL, 0);
if(*fd < 0){ if(*fd < 0){
error = strerror(errno); error = strerror(errno);
} else { } else {
...@@ -142,6 +142,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity, ...@@ -142,6 +142,9 @@ void ttyopen(CleanString fn, int baudrate, int bytesize, int parity,
//Set //Set
tio.c_oflag = 0; tio.c_oflag = 0;
tio.c_lflag |= ICANON; tio.c_lflag |= ICANON;
tio.c_cc[VMIN]=5;
tio.c_cc[VTIME]=0;
tcsetattr(*fd, TCSANOW, &tio); tcsetattr(*fd, TCSANOW, &tio);
*status = 1; *status = 1;
...@@ -198,12 +201,14 @@ void ttyavailable(int fd, int *r, int *fdo) ...@@ -198,12 +201,14 @@ void ttyavailable(int fd, int *r, int *fdo)
{ {
debug("ttyavailable"); debug("ttyavailable");
fd_set fds; fd_set fds;
struct timeval tv = DEVICE_TIMEOUT; struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(fd, &fds); FD_SET(fd, &fds);
*r = select(fd+1, &fds, NULL, NULL, NULL); *r = select(fd+1, &fds, NULL, NULL, &tv);
if(*r == -1) if(*r == -1)
die("select"); die("select");
*fdo = fd; *fdo = fd;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment