aboutsummaryrefslogtreecommitdiff
path: root/sercp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sercp.c')
-rw-r--r--sercp.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/sercp.c b/sercp.c
index d25af14..bbb607b 100644
--- a/sercp.c
+++ b/sercp.c
@@ -335,11 +335,16 @@ void FlushSerialPort() {
len = (size_t) ulNumBytes;
} while (len > 1);
#else
+ // the port is blocking on __APPLE__ (see OpenUart): read without waiting, or this
+ // hangs until the other side sends something
+ int flags = fcntl(serial_fd, F_GETFL);
+ fcntl(serial_fd, F_SETFL, flags | O_NONBLOCK);
tcflush(serial_fd, TCIOFLUSH);
do {
sleep_ms(100);
len = read (serial_fd, p_buff, 100);
} while (len > 1);
+ fcntl(serial_fd, F_SETFL, flags);
#endif
}
if (is_osc_progress_supported) {