Implement tc[io]flush methods & deprecate broken purge_buffers methods.
authorEric Schott <els6@psu.edu>
Fri, 4 Jan 2019 00:52:02 +0000 (19:52 -0500)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Fri, 18 Jan 2019 14:27:25 +0000 (15:27 +0100)
commited46f09c1ccd1351e003a200ba50e3e4778ac478
tree6b2005d53f58afbfb78a6c12099d258b558b94e6
parentbfbd47b7de65aa41c433945283d7bc0ebfa5576a
Implement tc[io]flush methods & deprecate broken purge_buffers methods.

The definitions for the SIO_RESET_PURGE_RX or SIO_RESET_PURGE_TX values are
with respect to the FTDI chip, not the CPU.  That is, when the FTDI chip
receives a USB control transfer request with the command SIO_RESET_PURGE_RX,
the FTDI chip empties the FIFO containing data received from the CPU awaiting
transfer out the serial port to the connected serial device (e.g., a modem).
Likewise, upon reception of the SIO_RESET_PURGE_TX command, the FTDI chip
empties the FIFO of data received from the attached serial device destined to
be transmitted to the CPU.

Unfortunately the coding of the previous releases of libfti assumed these
commands had the opposite effect. This resulted in the function
ftdi_usb_purge_tx_buffer clearing data received from the attached serial
device.  Similarly, the function ftdi_usb_purge_rx_buffer cleared the FTDI
FIFO containing data to be transmitted to the attached serial device.  More
seriously, this latter function clear the libftid's internal buffer of data
received from the serial device, destined to the application program.

This patch adds the ftdi_tciflush, ftdi_tcoflush, and ftdi_tcioflush functions
which emulate the Linux serial port tcflush(3) function.
examples/async.c
ftdipp/ftdi.cpp
ftdipp/ftdi.hpp
src/ftdi.c
src/ftdi.h
src/ftdi_stream.c