Skip to content

Commit

Permalink
set non-blocking serial port
Browse files Browse the repository at this point in the history
  • Loading branch information
igagis committed Sep 25, 2024
1 parent 34a2612 commit 713b7c2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/bedsidemon/serial_port.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ serial_port::serial_port(std::string_view port_filename, baud_rate baud_rate) :
if (tcsetattr(fd, TCSANOW, &newtermios) == -1) {
throw std::runtime_error("serial_port(): could not set serial port config");
}

if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
throw std::runtime_error("serial_port(): could not set non-blocking mode on the serial port");
}

scope_exit.release();
return fd;
}())
Expand Down

0 comments on commit 713b7c2

Please sign in to comment.