aboutsummaryrefslogtreecommitdiff
path: root/sercp.c
diff options
context:
space:
mode:
authorPavel Vymetálek <pavel@vym.cz>2026-11-03 09:36:20 +0100
committerPavel Vymetálek <pavel@vym.cz>2026-11-03 09:36:20 +0100
commit995a5af660ba3d3440cbcb5075e47d66aff2bf5d (patch)
tree20d3d7d300e4a3bb30d64225ab5e6dfcd5761f67 /sercp.c
parentc7aaabc166a88b0c21872a6131242803eb7c3953 (diff)
downloadsercp-pc-995a5af660ba3d3440cbcb5075e47d66aff2bf5d.tar.gz
Non-blocking read during flush serial port, thanks to Lordcoxis
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) {