I have recently cloned the project and I'm a bit confused by the documentation for flush, flushInput, and flushOutput when trying to implement the latter two for Windows.
Currently the comment for flush says it flushes the input and output buffers, while the comments for flushInput and flushOutput say that they flush only the input/output buffers. The Unix implementation of the three functions, however, uses tcdrain and tcflush, and according to this page, tcdrain() waits until all output written to the object referred to by fd has been transmitted., which I believe means that the data in the output buffer will be sent through the port before they get cleared, while the input buffer will be kept intact; tcflush() discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on the value of queue_selector, which I believe means that the data in the input buffer will be cleared, and the data in the output buffer will be cleared without being sent through the port.
Anyway, if flush means sending the data and then clearing the buffer, "flushing" an input buffer makes no sense to me (It's already sent to me, right?). So the best interpretation I can make is that flush flushes the output buffer, while flushInput and flushOutput clear the input/output buffers.
By the way, flushInput and flushOutput are currently unimplemented on windows. If they are meant to clear the buffer without sending their contents, PurgeComm will do the job.
I have recently cloned the project and I'm a bit confused by the documentation for
flush
,flushInput
, andflushOutput
when trying to implement the latter two for Windows.Currently the comment for
flush
says itflushes the input and output buffers
, while the comments forflushInput
andflushOutput
say that theyflush only the input/output buffers
. The Unix implementation of the three functions, however, usestcdrain
andtcflush
, and according to this page,tcdrain() waits until all output written to the object referred to by fd has been transmitted.
, which I believe means that the data in the output buffer will be sent through the port before they get cleared, while the input buffer will be kept intact;tcflush() discards data written to the object referred to by fd but not transmitted, or data received but not read, depending on the value of queue_selector
, which I believe means that the data in the input buffer will be cleared, and the data in the output buffer will be cleared without being sent through the port.Anyway, if flush means sending the data and then clearing the buffer, "flushing" an input buffer makes no sense to me (It's already sent to me, right?). So the best interpretation I can make is that
flush
flushes the output buffer, whileflushInput
andflushOutput
clear the input/output buffers.By the way,
flushInput
andflushOutput
are currently unimplemented on windows. If they are meant to clear the buffer without sending their contents,PurgeComm
will do the job.