uart: disable timeout on read <= 0
Signed-off-by: Le Jin <le.jin@siemens.com> Signed-off-by: Ivan Mikhaylov <ivan.mikhaylov@siemens.com>
This commit is contained in:
committed by
Tom Ingleby
parent
307a6f3bdd
commit
4450073721
@@ -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 */
|
||||
termio.c_cc[VTIME] = read; /* Set timeout in tenth seconds */
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user