On Tue, Mar 11, 2014 at 6:27 AM, Jef Driesen jef@libdivecomputer.org wrote:
I wonder if this is another case where the tcdrain() function isn't waiting properly until all bytes have been send out.
Assuming it is ftdi, we should have at least *tried* to do it since 3.8, but I really won't guarantee that it works. I'm assuming Hamish has something newer than that, but who knows.. As usual, I think Debian "stable" (also known as "bat shit crazy") is some ancient 3.2 kernel still, but all other distros should be much more up-to-date.
We had a similar problem with Suunto devices before.
As you know (but perhaps others don't) this isn't a Suunto problem per se - the actual *real* legacy serial cable should work fine, because on a real UART we generally have an easy way to check whether the send buffer has actually flushed out.
But the USB people originally (consciously) decided to not make USB -> serial be a standard, because their argument was that USB should replace serial lines, and USB serial dongles were thus "invalid". Morons with an agenda. As a result, there is no actual standard USB serial conversion model, and every single USB serial chip is a "hack" pretty much by definition.
And with simplex being *so* unusual, it doesn't get a lot of attention and testing, and since it's not some generic standard, it's always per-dongle-chip-driver.
I have been looking at the kernel history for the ftdi usb-serial driver, and there have been some changes related to waiting until the TX buffer is empty, so there could be something there as well. Which kernel version do you have (uname -a)?
There have been interface changes, but I don't think the functionality should have changed since 3.8 (and before that, we had no "wait for the dongle buffer" code at all for ftdi).
That said, see above about lack of test coverage. Maybe the interface changes broke something by mistake. And maybe it didn't work reliably to begin with ;)
So yeah, kernel version would be interesting, but no guarantees even then. Except for the guarantee that pre-3.8 it certainly didn't wait for the ftdi dongle to drain.
Linus