671 Commits

Author SHA1 Message Date
Jef Driesen
3927be9ced Fix the decoding of the serial number.
The serial number is stored as a plain 32bit integer, and the device
shows the hexadecimal representation. Because a BCD encoding can only
represent the lower digits (0-9) of a hexadecimal number, the upper
digits (A-F) got mangled.

Reported-By: Nick Shore <support@mac-dive.com>
2014-03-06 09:34:53 +01:00
Jef Driesen
0e11bad6c0 Use relative instead of absolute offests.
Although the settings sample will most likely always be located at the
start, it's better to be on the safe side and use an offset relative to
the start of the settings sample.

Reported-By: Nick Shore <support@mac-dive.com>
2014-03-06 08:25:15 +01:00
Jef Driesen
56e2dec726 Add support for configuring the OSTC3 settings.
Starting with firmware v1.23, the OSTC3 settings can be configured
through the USB interface. There are new commands for reading, writing
and restoring the settings to their default values.
2014-03-04 20:10:43 +01:00
Jef Driesen
23658b55c8 Fix a subtle bug in the previous commit.
The workaround in the previous commit has a bug. If after a reset, the
first entry happens to be located near the end of the TOC, then after a
few dives, the TOC will overflow and new entries will be written at the
start of the TOC. But the current algorithm starts scanning the TOC from
the start and abort the scan as soon as an empty entry is found. Thus if
there are less than 256 dives present, those entries near the end will
never be reached.

We now ignore all uninitialized entries, when searching for the most
recent dive. An explicit safety check is added in case dives are
unexpectedly interleaved with empty entries.
2014-03-04 20:10:42 +01:00
Jef Driesen
5d6408ed2f Ignore uninitialized header entries
Normally, the OSTC3 will always start writing dives at the first entry
in the TOC (Table of Contents). Therefore, uninitialized entries can
only be present after the last dive. However due to a minor firmware
bug, resetting the logbook erases the TOC but leaves the internal dive
counter unchanged. The consequence is that the next dive will still be
stored at the corresponding next TOC entry, while all previous TOC
entries have been erased.

As a workaround, we simply ignore uninitialized entries, unless we have
already found at least one dive.
2014-02-27 10:30:47 +01:00
Jef Driesen
db4d35cd3d Increase the internal log buffer.
With the switch to 4K data packets in the Icon HD backend, the internal
log buffer is no longer large enough for hexdumps of these data packets.
A hexdump needs twice the size of the binary data, plus some extra bytes
for the header and the terminating null byte.
2014-02-27 09:56:40 +01:00
Jef Driesen
9394773cd2 Increase the packet size again for the Icon HD.
The switch from downloading the entire data with a single large packet
to multiple smaller 256 byte packets, resulted in a considerable
performance regression. In one particular case, the difference was a
factor 6.7 slower!

I performed a small tests (using an Icon HD Net Ready) with 256, 1024
and 4096 byte packets, and the total time was respectively 21.0, 11.3
and 6.5 seconds. For a single large packet, the total time is only 5.9
seconds. Thus the difference with a 4096 byte packet is negligible.
2014-02-21 21:22:53 +01:00
Jef Driesen
991d0180d8 Autodetect the model using the version packet.
The model number stored in the main memory isn't always the most
reliable source of information, because there are devices where the
model number has not been filled in properly. Instead, we check the
product name in the version packet against the list with valid names,
and return the corresponding model number.

As an additional advantage, we no longer depend on the model number
supplied by the application for selecting the correct memory layout.
Nevertheless, the model parameter is kept for backwards compatibility.
2014-02-21 21:22:53 +01:00
Jef Driesen
2049bdb836 Remove an unnecessary function. 2014-02-21 21:22:53 +01:00
Jef Driesen
c718abbe06 Use the same packet size for all models.
The recommended packet size is 256 bytes, which matches the maximal
amount of data that can be read back from the internal memory chip.
Larger requests are split by the firmware into multiple blocks of
maximum 256 bytes.

Note that initially, we already used 256 byte packets for the newer
models, but it seems this was accidentally changed to only 64 bytes in
commit ad0e187c0c932121efa50763afc02771633cbd61.

The main benefit of this change is a simplification of the code, because
now there is no longer a difference between the Icon HD and Matrix
variant of the protocol.
2014-02-21 21:22:52 +01:00
Jef Driesen
c93314026c Use the same standard baudrate for all models.
The Mares Icon HD use a processor with integrated USB circuit, which
presents itself to the host system as a CDC-ACM device. Since there is
no external usb-serial chip involved, the baudrate and other serial
line parameters are irrelevant. By choosing the same settings as the
later models, which do use an usb-serial chip, we can completely avoid
the problem of unresponsive devices due to using the wrong baudrate.
2014-02-21 21:22:52 +01:00
Jef Driesen
2064c3d410 Fix the parsing of the serial number.
The serial number appears to be either a 24 or a 16 bit number, but
certainly not a 32bit number. Whether it's 24 or 16 bit is hard to
tell because the data we have available always contains a zero value
in the third byte.
2014-02-19 14:24:52 +01:00
Jef Driesen
f836e6a025 Add support for the Cressi Giotto.
The communication protocol and memory layout of the Cressi Giotto
appears to be identical to that of the Leonardo. The first byte seems
to be the model number, with 0x01 for the Leonardo and 0x04 for the
Giotto.
2014-02-19 14:22:31 +01:00
Jef Driesen
ba77b0ed24 Add support for gas switches. 2014-02-15 16:41:08 +01:00
Jef Driesen
d30b5c65fe Ignore invalid gas mixes.
Gas mixes that have been marked as disabled are stored as the value 0xF0.
When interpreted as an oxygen percentage, this results in an out of range
value. Therefore, these gas mixes should simply be ignored.
2014-02-15 16:41:07 +01:00
Jef Driesen
56aa3b6669 Merge branch 'release-0.4'
Integrate the bugfixes from the stable branch.
2014-02-06 20:31:27 +01:00
Jef Driesen
5ddca0b4f7 Fix a small spelling mistake. 2014-02-06 09:42:06 +01:00
Jef Driesen
3f7af8c349 Add support for the Dive Rite NiTek Q. 2014-02-06 09:42:06 +01:00
Jef Driesen
35003ced81 Add support for the OSTC 2C variant. 2014-01-26 21:51:33 +01:00
Jef Driesen
040679f76a Improve the progress events.
Reading the data packet in multiple smaller chunks greatly improves the
progress events. Instead of just two events, before and after the
download, there are now many intermediate events. This change also
allows to significantly reduce the timeout, from 30 seconds to just one
second, which avoids blocking for too long in case the device doesn't
respond at all.
2014-01-23 09:48:56 +01:00
Jef Driesen
4ae3a4f3ab Remove the infinite timeout.
An infinite timeout causes major problems, because if the device doesn't
respond at all, the read call will block forever. With the eon serial
line settings (1200 8N2), the total time to read the 2305 byte packet is
about 21.129 seconds. A timeout of 30 seconds should be plenty of time.
2014-01-23 09:48:56 +01:00
Jef Driesen
3f9f722219 Always use the ANSI variant of the Windows functions. 2014-01-22 20:02:58 +01:00
Jef Driesen
7b9bd1880c Add explicit casts for the msvc C++ compiler. 2014-01-22 20:02:58 +01:00
Jef Driesen
914e740087 Fix the memory layout for the VT4.x.
The VT4.x memory layout appears to be slightly different from the Atom
3.x memory layout. The logbook ringbuffer does start at offset 0x420
instead of 0x400.
2013-12-23 21:05:52 +01:00
Tim Wootton
459b1574b8 Add iconhd gas change event
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
2013-10-27 06:57:18 +01:00
Stephane Bensoussan
4c94460831 Use only 11 bits for the depth.
When using up to 14 bits for the depth, the resulting values are too
large in some cases. Most likely the upper bits are used to store
something else. Even with only 11 bits, the resulting depth range
(0-204.7m) should still be more than sufficient.
2013-10-21 11:41:19 +02:00
Jef Driesen
c524986175 Add support for the Scubapro/Uwatec Meridian.
The Uwatec Meridian protocol is identical to the Uwatec Smart/Galileo
protocol, except for some additional framing around each data packet,
and the switch from IrDA to usb-serial communication. For parsing, the
data format appears to be identical to the Galileo data format.
2013-10-19 10:11:15 +02:00
Jef Driesen
938839e694 Add support for the Scubapro XTender 5.
The XTender 5 is identical to the other models in the Zeagle N2iTiON3
family, and can be added to the list of supported devices without any
further changes.
2013-10-18 20:10:28 +02:00
Tim Wootton
734533e4d1 Fix units for atmospheric pressure for iconhd type
Was returning mbar, should have been bar.

Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
2013-10-15 11:49:46 +02:00
Tim Wootton
2af365cfb7 Adds support for DC_FIELD_ATMOSPHERIC to the iconhd parser
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
2013-10-12 20:33:52 +02:00
Patrick Valsecchi
8edbceaa4d Use the correct vtable for the Shearwater Petrel.
That was an harmless copy&paste error.

Signed-off-by: Patrick Valsecchi <patrick@thus.ch>
2013-10-11 15:41:57 +02:00
Jef Driesen
8e0355c354 Buffer the slip packet before sending.
On Mac OS X, sending the slip packet byte by byte results in an abysmal
performance. The first byte takes up to 160ms to send, and each next
byte approximately 250ms. The packet to request a data block is
typically 7 bytes large, and therefore takes about 1660ms to send.
Because a dive is transmitted as multiple smaller packets (typically
144 bytes without protocol overhead), downloading a single dive can
easily take several seconds.

However, when sending the entire slip packet at once, the time remains
roughly identical to sending just the first byte. The result is that
the time for sending a packet reduces significantly, proportional to
the length of the packet.

Under the hood, the slip packet is now internally buffered, and the
buffer is send only when the entire packet is complete, or whenever the
buffer gets full. But in practice, the buffer is large enough to always
store an entire packet.

In the original bug report, downloading 57 dives took about 40 minutes.
After applying the patch, that time reduced to only 5 minutes!
2013-09-21 11:30:39 +02:00
Jef Driesen
6f7495dd3e Add support for a new Uwatec Aladin 2G variant.
This new variant has a different model number and has switched to the
Uwatec Galileo data format.
2013-09-19 08:56:40 +02:00
Jef Driesen
043fc4166c Add support for the Oceanic OCi.
The new Oceanic OCi appears to be almost identical to the already
supported Oceanic OC1. The most important change is the different
location for the logbook ringbuffer.
2013-09-17 13:06:56 +02:00
Jef Driesen
b96780ce75 Add support for the Sherwood Amphos. 2013-09-16 09:57:34 +02:00
Jef Driesen
85fd0c524f Fix the memory layout descriptors.
The profile ringbuffer appears to be slightly smaller than expected for
some models. For the Mares Matrix (and all compatible devices) it ends
earlier, while for the Icon HD Net Ready it starts later.

This bug resulted in missing dives, because all remaining dives were
getting dropped once a dive that crossed the ringbuffer boundary was
reached.
2013-09-09 15:05:58 +02:00
Jef Driesen
1bfcb8c3c1 Mark the Oceanic Veo 2.0 as a non air integrated model. 2013-09-05 20:41:46 +02:00
Jef Driesen
1331db75cb Fix the memory layout for the Atom 3.x and VT4.x.
The logbook ringbuffer appears to start at offset 0x400 instead of
0x240. Since these ringbuffer boundaries have to be taken taken into
account only once the ringbuffer has been filled completely, this bug
affects users with more than 200 dives only. Thus, no surprise it didn't
get noticed earlier.
2013-09-05 08:21:25 +02:00
Jef Driesen
b35e07b71b Add cancellation support to several backends.
Some backends are technically capable of supporting cancellation, but
still lacked the necessary code to enable it.
2013-09-03 20:13:49 +02:00
Jef Driesen
888b6ab03f Disable the cancellation callback during shutdown.
Several backends require a shutdown command to be send before closing
the connection. If such a command gets cancelled, that might result in
an unclean shutdown. Backends where this is problematic can always
ignore cancellation requests internally, but it's less error-prone (and
much easier) to simply disable the cancellation callback for all
backends, before closing the connection.
2013-09-03 20:09:31 +02:00
Jef Driesen
22a8bc70ea Add a warning to the firmware update code. 2013-08-23 13:42:55 +02:00
Jef Driesen
bc89e0a3de Autodetect the bootloader protocol variant.
When updating the firmware while the OSTC is running in normal mode, the
V2 protocol should be used. However, the OSTC can also be rebooted from
the menu or reset using the magnetic switch, and then the V1 protocol
should be used. The only difference with the V2 protocol is the slower
baudrate (19200 vs 115200).

True autodetection of the protocol variant is difficult, because the
bootloader will abort the firmware update when not receiving a 0xC1
byte. But we can still take advantage of the fact that the normal
firmware does ignore any 0xC1 bytes sent at the wrong baudrate, and
probe with the V1 protocol first. If the bootloader is already running,
it will respond immediately and we're done. If the normal firmware is
still running, it won't respond and the probing with the V1 protocol
will fail. If we then switch to the V2 protocol, the firmware update
will continue as before.

The result is a firmware updater which supports both bootloader
protocols without requiring any manual configuration.
2013-08-22 09:15:55 +02:00
Jef Driesen
14286e8236 Add support for updating the HW OSTC firmware.
Only the bootloader V2 protocol is supported for now.
2013-08-22 09:15:55 +02:00
Jef Driesen
222ba81157 Add a parser for Intel HEX files. 2013-08-22 09:15:55 +02:00
Alexander Neumann
37cb54c376 Add Mares Puck 2 dive computer
This dive computer has the same enclosure as the Mares Puck, but the
wire protocol is that of the Puck Pro. The original software identifies
it as a "Mares Puck 2", and the handshake string also contains the
sequence "PUCK 2", so this string is used to identify the device.
2013-08-12 13:11:07 +02:00
Michael Andreen
5f8da384e6 Identify event 0x07 on Suunto d9-style computers as Below Floor.
This event is on when accumulating deco time. Once you reach the floor
deco time will start decreasing and the event will stop. Going below the
floor again will re-activate the event.

Signed-off-by: Michael Andreen <harv@ruin.nu>
2013-08-05 23:02:19 +02:00
Jef Driesen
456365366c Decode the IrDA device address as little endian.
This is only a cosmetic change, to make the IrDA device address on
Windows consistent with the address Linux. There is no functional
difference because the address is always serialized and deserialized
internally, and applications shouldn't care about the actual number.

Anyway, the difference in endianness is easy to notice because the
Uwatec Smart family of devices use the serial number as the IrDA device
address. On Linux, the address was identical to the serial number, while
on Windows the byte order was reversed.
2013-08-05 22:45:48 +02:00
Jef Driesen
3d82c5f9cd Add logging to the IrDA communication. 2013-08-05 22:45:48 +02:00
Jef Driesen
9ce8888e37 Log the device name of the serial port. 2013-08-05 22:42:24 +02:00
Jef Driesen
d44053a994 Add internal support for enumerating serial ports.
For the time being, the serial port enumeration code is of very limited
use. It's not used anywhere in the library, and as an internal api it's
also not available to applications. It serves mainly as a reference
implementation for future use.
2013-08-05 22:40:07 +02:00