diff options
| author | Pavel Vymetálek <pavel@vym.cz> | 2026-11-03 09:36:20 +0100 |
|---|---|---|
| committer | Pavel Vymetálek <pavel@vym.cz> | 2026-11-03 09:36:20 +0100 |
| commit | 995a5af660ba3d3440cbcb5075e47d66aff2bf5d (patch) | |
| tree | 20d3d7d300e4a3bb30d64225ab5e6dfcd5761f67 /sercp.c | |
| parent | c7aaabc166a88b0c21872a6131242803eb7c3953 (diff) | |
| download | sercp-pc-995a5af660ba3d3440cbcb5075e47d66aff2bf5d.tar.gz | |
Non-blocking read during flush serial port, thanks to Lordcoxis
Diffstat (limited to 'sercp.c')
| -rw-r--r-- | sercp.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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) { |
