A bulk transfer of more than 8K of data takes about one second with the
Cobalt. Because we use a one second timeout combined with a 10K buffer,
such a transfer can easily exceed the timeout. Normally this shouldn't
be a problem because the leftover data is supposed to be received with
the next transfer. However to break out of the loop we check the actual
number of bytes received, and ignore the libusb LIBUSB_ERROR_TIMEOUT
return code.
To fix this problem, the internal buffer is reduced to 8K, and the
timeout is increased to 2 seconds. This should avoid hitting the timeout
and allows to consider LIBUSB_ERROR_TIMEOUT a fatal error.
On Mac OS X (and probably the other BSD's too), the ioctl() syscall
takes an 'unsigned long' integer as the request parameter. On 64bit
systems this is a 64bit type, while on 32bit systems it's a 32bit type.
Some of the request constants are defined as 32 bit negative numbers.
Casting it to a 64bit value will perform a sign extension operation to
preserve the negative value. Because this results in a different request
code when interpreted as an unsigned integer, the ioctl() call fails
with ENOTTY. For example TIOCMBIS is defined as 0x8004746c and becomes
0xffffffff8004746 after the sign extension.
Linux 64bit is unaffected by this problem. None of the request constants
has the sign bit set, and thus the sign extension has no effect. For
example TIOCMBIS is defined as 0x5416.
By using an unsigned integer type, the sign extension can be avoided. We
use the 'unsigned long' type in case one of the request constants
happens to be defined as a 64bit number.
Since automake 1.12, the warnings in the category 'extra-portability'
are now enabled by '-Wall'. Because of this change, linking libtool
archives requires the new AM_PROG_AR macro.
It looks like the Icon HD erases old dives partially with 0xFF bytes
before overwriting them with new dives. If the head of the oldest dive
has been erased, the length field which is stored in the first 4 bytes
is erased as well, and we can use it to detect the last dive.
For development snapshots, a 'devel' suffix is added to distinguish from
the final release. If necessary, the suffix can also be used for 'alpha'
and 'beta' releases.
The Veo 1.0 has very limited memory and doesn't have a logbook and
profile ringbuffer. Hence downloading dives isn't really supported, but
even this limited amount of data might be useful for someone.
Sometimes there are a few garbages bytes received before the preamble
bytes. This typically happens when trying to download again after a
failed attempt. However trying to flush them immediately after opening
the serial port doesn't work.
When the OSTC receives the download dives command, it responds
immediately with the preamble bytes. But then it does a linear search
through its internal memory to locate the end-of-profile marker. As a
result the response time increases when the marker is located near the
end of the memory area. In the worst case scenario, the response time
can exceed the 3 second read timeout with a few milliseconds.
Since the required timeout depends on the total amount of profile
memory, this problem was indirectly introduced with firmware v1.91,
which doubled the amount of profile memory from 32K to 64K.
When using half-duplex communication (e.g. only a single wire for both
Tx and Rx) a data packet needs to be transmitted entirely before
attempting to switch into receiving mode.
For legacy serial hardware, the tcdrain() probably works as advertised,
and waits until the data has been transmitted. However for common
usb-serial converters, the hardware doesn't provide any feedback to the
driver, and the tcdrain() function can only wait until the data has been
transmitted to the usb-serial chip. There is no guarantee that the data
has actually been transmitted by the usb-serial chip.
As a workaround, we wait at least the minimum amount of time required to
transmit the data packet over a serial line, taking into account the
current configuration.
The OSTC doesn't store the start of the dive, but the exit time. Hence
the dive time needs to be substracted.
For dives with format version 0x21, we prefer the total dive time in
seconds stored in the extended header. This time value also includes the
shallow parts of the dive, and therefore yields the most accurate start
time. The dive time is rounded down towards the nearest minute, to match
the value displayed by the ostc. For dives with the older format version
0x20, this value isn't available and we default to the normal dive time.
When the dive mode setting is set to air, the oxygen percentage stored
in the header is different from the expected 21%. It might be the last
used nitrox percentage.
The assumption that two consecutive dive profiles are stored without any
gaps in between them, appears to be incorrect in some cases. Instead of
failing with an error we just skip those gaps now.
We received a report of a Darwin Air device which has a very high error
rate. The majority of the echo packets is incorrect, but since this
doesn't seem to have any effect on the actual data packet, we can just
ignore this error. If there happens to be a more serious error, it will
be detect in the data packet.
Sometimes there were also a some garbage bytes received at startup.
Adding a small delay seems to fix this.
The linux USB CDC-ACM driver, which is used by the Mares Icon HD
interface, doesn't support the ioctl's to configure a custom baudrate.
But since the actual baudrate doesn't seem to matter at all, we revert
back to the nearest standard baudrate.
Because custom baudrates are confirmed to be supported on Windows and
Mac OS X, those platforms can keep using the non-standard baudrate.
When trying to send the commands as fast as possible, without any delay,
the failure rate is very high. Almost every single packet fails with a
timeout at first. Retrying the packet works, but those many timeouts
make the download extremely slow. Adding a small delay avoids the much
more expensive timeout and speeds up the transfer significantly.
The Darwin and Darwin Air share a very similar layout, but with a few
differences here and there. Unfortunately, there seems to be no way to
autodetect the exact model during the download. Therefore, an extra
model parameter is added to select the appropriate model manually.