Hi,

an updated version of the patch has been applied, thanks a lot Eric!

Link to the patchset:
http://developer.intra2net.com/git/?p=libftdi;a=commit;h=ed46f09c1ccd1351e003a200ba50e3e4778ac478
http://developer.intra2net.com/git/?p=libftdi;a=commit;h=c834fe721339f0fe21be6300db0b71f9fa22b077
http://developer.intra2net.com/git/?p=libftdi;a=commit;h=41b114dab8a6a6324d56f9b4e04466316ae23e8a

Most important commit message:

***********************************
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.
***********************************

There is another patch I didn't apply which are journal notes from testing
the purge functionality. I've attached the patch to this email so it's archived
in various mail archives.

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]   
>From 783630732f27dbac6bfc3c3ca2fe8576213b7b1e Mon Sep 17 00:00:00 2001
From: Eric Schott <[email protected]>
Date: Thu, 3 Jan 2019 19:59:21 -0500
Subject: [PATCH 4/4] Add samples of purge_test outputs.

---
 examples/purge_test_journal/README.txt             |  1 +
 examples/purge_test_journal/ftdi-flush-1200-60.out | 33 +++++++++++++++++++++
 examples/purge_test_journal/ftdi-flush-9600-60.out | 33 +++++++++++++++++++++
 examples/purge_test_journal/ftdi-purge-1200-60.out | 34 ++++++++++++++++++++++
 examples/purge_test_journal/ftdi-purge-9600-60.out | 34 ++++++++++++++++++++++
 examples/purge_test_journal/linux-9600-60.out      | 32 ++++++++++++++++++++
 6 files changed, 167 insertions(+)
 create mode 100644 examples/purge_test_journal/README.txt
 create mode 100644 examples/purge_test_journal/ftdi-flush-1200-60.out
 create mode 100644 examples/purge_test_journal/ftdi-flush-9600-60.out
 create mode 100644 examples/purge_test_journal/ftdi-purge-1200-60.out
 create mode 100644 examples/purge_test_journal/ftdi-purge-9600-60.out
 create mode 100644 examples/purge_test_journal/linux-9600-60.out

diff --git a/examples/purge_test_journal/README.txt 
b/examples/purge_test_journal/README.txt
new file mode 100644
index 0000000..30e0951
--- /dev/null
+++ b/examples/purge_test_journal/README.txt
@@ -0,0 +1 @@
+This directory contains the output of runs of the purge_test programs.
diff --git a/examples/purge_test_journal/ftdi-flush-1200-60.out 
b/examples/purge_test_journal/ftdi-flush-1200-60.out
new file mode 100644
index 0000000..098cfaa
--- /dev/null
+++ b/examples/purge_test_journal/ftdi-flush-1200-60.out
@@ -0,0 +1,33 @@
+Purge (tcflush) test for device i:0x403:0x6011
+Note: libftdi w/ new flush methods
+FTDI chip type is 5 (4232H)
+# purge_test -b 1200 -n 60 i:0x403:0x6011
+60 chars at 1200 baud takes about 500 ms to transmit
+TX Message is "JKLMNOPQRSTUVWXYZ[\]^_AabcdefghijklmnopqrstuvwxyzBabcdefghij"
+
+********  Test purge Input-only; expect last portion of message  ********
+  --              Flushing UART
+  --       0.2 ms Write completes; delaying to TX midpoint (249.8 ms)
+  --     250.2 ms Issuing Input-only flush (purge)
+  --     250.3 ms Calling drain to wait for transmit to complete
+  --     518.4 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --     552.0 ms Reading data.
+  --     552.2 ms Read returns 31 bytes; msg: "ghijklmnopqrstuvwxyzBabcdefghij"
+
+********  Test purge Output-only; expect first portion of message  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (249.9 ms)
+  --     250.1 ms Issuing Output-only flush (purge)
+  --     250.3 ms Calling drain to wait for transmit to complete
+  --     267.2 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --     300.8 ms Reading data.
+  --     301.0 ms Read returns 31 bytes; msg: "JKLMNOPQRSTUVWXYZ[\]^_Aabcdefgh"
+
+********  Test purge Input+Output; expect mid-message characters  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (249.9 ms)
+  --     250.1 ms Issuing Input+Output flush (purge)
+  --     250.3 ms Calling drain to wait for transmit to complete
+  --     267.3 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --     300.9 ms Reading data.
+  --     301.1 ms Read returns 2 bytes; msg: "gh"
diff --git a/examples/purge_test_journal/ftdi-flush-9600-60.out 
b/examples/purge_test_journal/ftdi-flush-9600-60.out
new file mode 100644
index 0000000..4e146ee
--- /dev/null
+++ b/examples/purge_test_journal/ftdi-flush-9600-60.out
@@ -0,0 +1,33 @@
+Purge (tcflush) test for device i:0x403:0x6011
+Note: libftdi w/ new flush methods
+FTDI chip type is 5 (4232H)
+# purge_test -b 9600 -n 60 i:0x403:0x6011
+60 chars at 9600 baud takes about 63 ms to transmit
+TX Message is "789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_Aabcdefghijklmnopqr"
+
+********  Test purge Input-only; expect last portion of message  ********
+  --              Flushing UART
+  --       0.3 ms Write completes; delaying to TX midpoint (31.0 ms)
+  --      31.5 ms Issuing Input-only flush (purge)
+  --      31.8 ms Calling drain to wait for transmit to complete
+  --      67.1 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      71.5 ms Reading data.
+  --      71.8 ms Read returns 30 bytes; msg: "UVWXYZ[\]^_Aabcdefghijklmnopqr"
+
+********  Test purge Output-only; expect first portion of message  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (31.2 ms)
+  --      31.3 ms Issuing Output-only flush (purge)
+  --      31.5 ms Calling drain to wait for transmit to complete
+  --      33.7 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      38.0 ms Reading data.
+  --      38.1 ms Read returns 31 bytes; msg: "789:;<=>?@ABCDEFGHIJKLMNOPQRSTU"
+
+********  Test purge Input+Output; expect mid-message characters  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (31.2 ms)
+  --      31.5 ms Issuing Input+Output flush (purge)
+  --      31.7 ms Calling drain to wait for transmit to complete
+  --      34.1 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      38.4 ms Reading data.
+  --      41.7 ms Read returns 2 bytes; msg: "UV"
diff --git a/examples/purge_test_journal/ftdi-purge-1200-60.out 
b/examples/purge_test_journal/ftdi-purge-1200-60.out
new file mode 100644
index 0000000..689eef6
--- /dev/null
+++ b/examples/purge_test_journal/ftdi-purge-1200-60.out
@@ -0,0 +1,34 @@
+Purge (tcflush) test for device i:0x403:0x6011
+Note: libftdi w/ deprecated purge
+FTDI chip type is 5 (4232H)
+# purge_test -b 1200 -n 60 -P i:0x403:0x6011
+60 chars at 1200 baud takes about 500 ms to transmit
+TX Message is "23456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_Aabcdefghijklm"
+
+********  Test purge Input-only; expect last portion of message  ********
+  --              Flushing UART
+  --       0.2 ms Write completes; delaying to TX midpoint (249.8 ms)
+  --     250.3 ms Issuing Input-only flush (purge)
+  --     250.5 ms Calling drain to wait for transmit to complete
+  --     267.7 ms Drain() completed too early; expected at least 450.0 ms
+                  Delaying for 282.3 ms
+  --     550.3 ms Reading data.
+  --     550.7 ms Read returns 31 bytes; msg: "23456789:;<=>?@ABCDEFGHIJKLMNOP"
+
+********  Test purge Output-only; expect first portion of message  ********
+  --              Flushing UART
+  --       0.2 ms Write completes; delaying to TX midpoint (249.8 ms)
+  --     250.3 ms Issuing Output-only flush (purge)
+  --     250.4 ms Calling drain to wait for transmit to complete
+  --     518.7 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --     552.3 ms Reading data.
+  --     552.8 ms Read returns 31 bytes; msg: "OPQRSTUVWXYZ[\]^_Aabcdefghijklm"
+
+********  Test purge Input+Output; expect mid-message characters  ********
+  --              Flushing UART
+  --       0.3 ms Write completes; delaying to TX midpoint (249.7 ms)
+  --     250.3 ms Issuing Input+Output flush (purge)
+  --     250.8 ms Calling drain to wait for transmit to complete
+  --     267.9 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --     301.4 ms Reading data.
+  --     301.8 ms Read returns 2 bytes; msg: "OP"
diff --git a/examples/purge_test_journal/ftdi-purge-9600-60.out 
b/examples/purge_test_journal/ftdi-purge-9600-60.out
new file mode 100644
index 0000000..80cac43
--- /dev/null
+++ b/examples/purge_test_journal/ftdi-purge-9600-60.out
@@ -0,0 +1,34 @@
+Purge (tcflush) test for device i:0x403:0x6011
+Note: libftdi w/ deprecated purge
+FTDI chip type is 5 (4232H)
+# purge_test -b 9600 -n 60 -P i:0x403:0x6011
+60 chars at 9600 baud takes about 63 ms to transmit
+TX Message is "123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_Aabcdefghijkl"
+
+********  Test purge Input-only; expect last portion of message  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (31.1 ms)
+  --      31.5 ms Issuing Input-only flush (purge)
+  --      31.6 ms Calling drain to wait for transmit to complete
+  --      34.0 ms Drain() completed too early; expected at least 56.2 ms
+                  Delaying for 34.7 ms
+  --      69.0 ms Reading data.
+  --      69.2 ms Read returns 32 bytes; msg: 
"123456789:;<=>?@ABCDEFGHIJKLMNOP"
+
+********  Test purge Output-only; expect first portion of message  ********
+  --              Flushing UART
+  --       0.1 ms Write completes; delaying to TX midpoint (31.1 ms)
+  --      31.5 ms Issuing Output-only flush (purge)
+  --      31.6 ms Calling drain to wait for transmit to complete
+  --      66.4 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      70.8 ms Reading data.
+  --      71.0 ms Read returns 30 bytes; msg: "OPQRSTUVWXYZ[\]^_Aabcdefghijkl"
+
+********  Test purge Input+Output; expect mid-message characters  ********
+  --              Flushing UART
+  --       0.3 ms Write completes; delaying to TX midpoint (31.0 ms)
+  --      31.5 ms Issuing Input+Output flush (purge)
+  --      32.0 ms Calling drain to wait for transmit to complete
+  --      34.4 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      38.6 ms Reading data.
+  --      41.3 ms Read returns 2 bytes; msg: "OP"
diff --git a/examples/purge_test_journal/linux-9600-60.out 
b/examples/purge_test_journal/linux-9600-60.out
new file mode 100644
index 0000000..2dfe89f
--- /dev/null
+++ b/examples/purge_test_journal/linux-9600-60.out
@@ -0,0 +1,32 @@
+Purge (tcflush) test for device /dev/ttyUSB0
+Note: Linux kernel driver
+# purge_test -b 9600 -n 60 /dev/ttyUSB0
+60 chars at 9600 baud takes about 63 ms to transmit
+TX Message is "CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_AabcdefghijklmnopqrstuvwxyzBabc"
+
+********  Test purge Input-only; expect last portion of message  ********
+  --              Flushing UART
+  --       0.0 ms Write completes; delaying to TX midpoint (31.2 ms)
+  --      31.5 ms Issuing Input-only flush (purge)
+  --      31.5 ms Calling drain to wait for transmit to complete
+  --      62.5 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      66.8 ms Reading data.
+  --      66.8 ms Read returns 31 bytes; msg: "]^_AabcdefghijklmnopqrstuvwxyzB"
+
+********  Test purge Output-only; expect first portion of message  ********
+  --              Flushing UART
+  --       0.0 ms Write completes; delaying to TX midpoint (31.2 ms)
+  --      31.4 ms Issuing Output-only flush (purge)
+  --      31.5 ms Calling drain to wait for transmit to complete
+  --      62.5 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      66.8 ms Reading data.
+  --      66.9 ms Read returns 56 bytes; msg: 
"CDEFGHIJKLMNOPQRSTUVWXYZ[\]^_Aabcdefghijklmnopqrstuvwxyz"
+
+********  Test purge Input+Output; expect mid-message characters  ********
+  --              Flushing UART
+  --       0.0 ms Write completes; delaying to TX midpoint (31.2 ms)
+  --      31.5 ms Issuing Input+Output flush (purge)
+  --      31.6 ms Calling drain to wait for transmit to complete
+  --      65.9 ms Drain() reports completed; timing OK; delaying for 4 bytes
+  --      70.2 ms Reading data.
+  --      70.3 ms Read returns 31 bytes; msg: "\]^_Aabcdefghijklmnopqrstuvwxyz"
-- 
2.7.4

Reply via email to