Skip to content

Commit

Permalink
core: fix destruction of serial connection
Browse files Browse the repository at this point in the history
When nothing weas being received over serial the destruction of the
serial connection hung waiting for a read to complete.

By using a timeout every second, we can recover after one second.
It's not optimal but better than stalling completely.
  • Loading branch information
julianoes committed Jul 22, 2019
1 parent bd1e308 commit 9b8fe0d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/serial_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ ConnectionResult SerialConnection::setup_port()
tc.c_cflag &= ~(CSIZE | PARENB | CRTSCTS);
tc.c_cflag |= CS8;

tc.c_cc[VMIN] = 1; // We want at least 1 byte to be available.
tc.c_cc[VTIME] = 0; // We don't timeout but wait indefinitely.
tc.c_cc[VMIN] = 0; // We are ok with 0 bytes.
tc.c_cc[VTIME] = 10; // Timeout after 1 second.
#endif

#if defined(LINUX) || defined(APPLE)
Expand Down

0 comments on commit 9b8fe0d

Please sign in to comment.