On Wed, 20 Mar 2024 at 10:19, 'Dirk Hohndel' via Subsurface Divelog
<
subsurfac...@googlegroups.com> wrote:
>
> This is odd. We fail when trying to set RTS. That's a bug that I haven't seen before. Jef, does this ring any bells?
The RTS thing is a red herring. The old Suunto serial setup is a
two-wire half-duplex thing and physically doesn't even _have_ RTS/CTS
pins.
So I think the error comes from the device having been unplugged.
The real issue is this:
[2.747701] INFO: Read: size=26,
data=000000000000000000000B2A09130C1713001500001401000022
[358.364738] INFO: Read: size=0, data=
IOW we have that almost six *minute* delay in between the 26-byte read
and the "no more data" read.
I think the "Failed to set RTS" is more likely to be due to Arnaud
having unplugged the cable or similar.
So while the RTS error shouldn't matter, I doubt any future IO would
have worked anyway.
No, I think the real error happened much much earlier. That sequence
starts out with us sending the "read first dive" command:
[1.764555] INFO: Write: size=3, data=08A5AD
where 08 is just "first dive" (09 means "next dive"), A5 is the "read
dive" command, and "AD" is just the checksum (xor of 08 and A5).
And then we get back
INFO: RTS: value=0
INFO: Read: size=2, data=0820
INFO: Read: size=33,
data=00001A1A807D7A00000000000000000000000000000000000000000000000000AF
INFO: Read: size=2, data=0820
INFO: Read: size=33,
data=000000000000000000000000000000000000000000000000000000000000000028
INFO: Read: size=2, data=0819
INFO: Read: size=26,
data=000000000000000000000B2A09130C1713001500001401000022
where we read a two-byte header that is "08" (for reply to our 08),
and the second is the length of the reply (so hex 20 is 32 bytes).
Then that 33-byte data that comes next is the reply and the XOR of the
data.
So that last packet is 08 19, so it says "25 bytes of data", and yes,
we get 26 bytes (because the XOR checksum).
And then we don't do anything at all. We've gotten all the data, but
nothing happens.
We actually have that code, but it's #if'ed out:
// If a package is smaller than $SZ_PACKET bytes,
// we assume it's the last packet and the transmission can be
// finished early. However, this approach does not work if the
// last packet is exactly $SZ_PACKET bytes long!
#if 0
if (len != SZ_PACKET)
break;
#endif
but that code has been if'ed out for a long long long time, since 2008
(commit ce2f9359cba5: "Removed the interface detection code since it
is no longer required").
So now the code actually replies on the timeout, but the timeout
should have been one *second*, not 356 seconds. So we get that timeout
much *MUCH* too late:
INFO: Read: size=0, data=
and at that point we go "ok, the first dive is done". But it took six
minutes to make that decision, and I'm pretty sure the Vyper has long
since gone to sleep.
I suspect that removing the #if 0 would make it work (until we hit a
dive that is an exact multiple of 32 bytes long), but the real issue
is that the timeout never happened.
Linus