From 995a5af660ba3d3440cbcb5075e47d66aff2bf5d Mon Sep 17 00:00:00 2001 From: Pavel Vymetálek Date: Tue, 3 Nov 2026 09:36:20 +0100 Subject: Non-blocking read during flush serial port, thanks to Lordcoxis --- sercp.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sercp.c') 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) { -- cgit