1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

Workaround for drivers with broken flush

term_flush() does not work with some drivers. If we try to drain or even
close the port while there are still data in it's output buffers *and*
flow-control is enabled, we may block forever. So we "fake" a flush, by
temporarily setting f/c to none, waiting for any data in the output
buffer to drain, and then reseting f/c to it's original setting.
This commit is contained in:
Nick Patavalis
2017-12-20 09:48:00 +02:00
parent e6653b45b5
commit 89be292023
3 changed files with 79 additions and 0 deletions

12
term.h
View File

@ -65,6 +65,7 @@
* F term_get_mctl - Get modem control signals status
* F term_drain - drain the output from the terminal buffer
* F term_flush - discard terminal input and output queue contents
* F term_fake_flush - discard terminal input and output queue contents
* F term_break - generate a break condition on a device
* F term_baud_up - return next higher baudrate
* F term_baud_down - return next lower baudrate
@ -661,6 +662,17 @@ int term_drain (int fd);
*/
int term_flush (int fd);
/* F term_fake_flush
*
* Fake a term_flush, by temporarily configuring the device associated
* with the managed fd to no flow-control and waiting until its output
* queue drains.
*
* Returns negative on failure, non-negative on success.
*/
int term_fake_flush(int fd);
/* F term_break
*
* This function generates a break condition on the device associated