uart: disable timeout on read <= 0
@@ -692,7 +692,14 @@ mraa_uart_set_timeout(mraa_uart_context dev, int read, int write, int interchar)
read = 1;
}
termio.c_lflag &= ~ICANON; /* Set non-canonical mode */
+ if (read > 0) {
termio.c_cc[VTIME] = read; /* Set timeout in tenth seconds */
+ termio.c_cc[VMIN] = 0;
+ } else {
+ termio.c_cc[VTIME] = 0; /* read <= 0 will disable timeout */
+ termio.c_cc[VMIN] = 1;
+ }
+
if (tcsetattr(dev->fd, TCSANOW, &termio) < 0) {
syslog(LOG_ERR, "uart%i: set_timeout: tcsetattr() failed: %s", dev->index, strerror(errno));
return MRAA_ERROR_FEATURE_NOT_SUPPORTED;
