UartComIF: set O_NONBLOCK in canonical mode

When using the non-canonical mode, the file descriptor can be opened
in blocking mode because the VTIME and VMIN termios parameters are
used to configure non-blocking mode. However, in canonical mode, the fd needs to be opened with O_NONBLOCK
This commit is contained in:
Robin Müller 2021-08-22 19:48:35 +02:00
parent 7d0377845b
commit 5454169e20
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -60,7 +60,13 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
struct termios options = {};
std::string deviceFile = uartCookie->getDeviceFile();
int fd = open(deviceFile.c_str(), O_RDWR);
int flags = O_RDWR;
if(uartCookie->getUartMode() == UartModes::CANONICAL) {
// In non-canonical mode, don't specify O_NONBLOCK because these properties will be
// controlled by the VTIME and VMIN parameters and O_NONBLOCK would override this
flags |= O_NONBLOCK;
}
int fd = open(deviceFile.c_str(), flags);
if (fd < 0) {
sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile <<