1110 Commits

Author SHA1 Message Date
Jef Driesen
99300d4e37 Implement ndl/deco support for the Hollis TX1. 2015-10-28 08:27:24 +01:00
Jef Driesen
3b0e36ccbf Implement ndl/deco support for the Tusa Zen. 2015-10-28 08:27:24 +01:00
Jef Driesen
7341403f73 Fix the temperature for the Tusa Zen. 2015-10-28 08:27:24 +01:00
Jef Driesen
95aa477129 Cache the parser data internally. 2015-10-28 08:27:24 +01:00
Jef Driesen
6f89e445e3 Convert the internal tank id to an index.
The internal Uwatec tank id should be converted to the libdivecomputer
tank index. If there is no corresponding tank, the tank pressure samples
are dropped for the following reasons:

Some models appear to record an absolute tank pressure sample, even if
there is no pressure sensor attached to the corresponding tank. In this
case only the tank index changes. The sample value simply retains the
last pressure of the previous tank. Since we don't have any real
pressure data, dropping those samples is fine.
2015-10-28 08:26:58 +01:00
Jef Driesen
a21f60e0bc Handle a libusb timeout as a non fatal error.
Dives are downloaded using bulk transfers with an 8K buffer. Normally
the 2 second timeout is more than sufficient, and the timeout should
never expire, unless there is some serious communcation problem. But
nevertheless, users are reporting timeouts for dives having a length
that is an exact multiple of the USB packet size (64 bytes). In that
case, libusb reports a timeout with an non-zero amount of bytes
received. Despite the timeout, the received data contains a complete
dive.

I suspect libusb is somehow unable to determine whether the transfer is
complete and therefore waits until the timeout expires. For transfers
that are not a multiple of the USB packet size, the end of the transfer
is indicated by the last incomplete packet. This is not the case if the
length is an exact multiple of the USB packet size. This problem is
usually solved by sending a zero-length packet. Maybe the USB stack of
the Cobalt is not sending such a zero-length packet?

Atomics will address the problem with a Coblat 2 firmware upgrade, that
will simply append two zero bytes if the length is a multiple of 64
bytes. As a workaround for older firmware versions, we ignore the
timeout and process all received data. This shouldn't have any
disadvantages. An incomplete dive, for example due to a real timeout,
will now be detected by means of the minimum length and/or the checksum.
2015-10-28 08:08:17 +01:00
Robert C. Helling
00e0cfa0ab Mention Shearwater Nerd alongside with Petrel 2
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2015-10-16 19:55:57 +02:00
Janice
0efa420b71 Convert ndl/deco time to seconds. 2015-10-14 09:11:47 +02:00
Giorgio Marzano
95bdea93cd Use the correct memory layout and packet size. 2015-10-05 15:11:34 +02:00
Giorgio Marzano
cb06adef35 Add support for the Mares Smart Apnea.
The Mares Smart Apnea uses a different data format than the regular
Smart, because it records not only a summary of each freedive in the
session, but also a full depth profile.

Because both the regular Smart and the Smart Apnea have the same model
number (0x10), another way to distinguish the two variants is needed.
Therefore, the Smart Apnea gets a modified model number, with one of the
higher bit set. The actual type is detected from the contents of the
version packet.

The new Smart Apnea is also capable of recording multiple samples per
second (e.g. 2, 4 or 8). But since our smallest unit of time is one
second, we can't represent this, and the extra samples will get dropped
for now.
2015-09-30 08:19:59 +02:00
Jef Driesen
3fa606a8a2 Fix the gas switches for Galileo Trimix.
The Galileo Trimix supports up to 10 tanks and gas mixes. However, the
existing alarm based gas switch events have only 2 bits available, and
can support at most 4 gas mixes. Therefore, the trimix variant stores
another 4 bit value in the second alarm byte.

For the first three gas mixes (and possibly also the fourth), both alarm
bytes appear to be always set to the same value. For the higher mixes,
the value in the first alarm byte is always zero. This doesn't cause any
problems, because in the data stream the second alarm byte is stored
after the first one, and our final value is always the last one.

The non-trimix variant also has the second alarm byte, but the gas mix
bits appear to be always zero. In order to avoid taking this zero as the
final value, a separate table is used for the trimix variant.
2015-09-17 11:24:16 +02:00
Jef Driesen
52453f080d Add support for the tank field.
The air integrated uwatec aladin models do record the total consumption,
and not the begin/end pressure. Returning the total consumption as the
begin pressure, combined with a zero end pressure is strictly speaking
not correct, but it still provides useful information.
2015-09-11 22:41:46 +02:00
Jef Driesen
ddbcdeecbb Ignore disconnected O2 sensors.
Even if there are no O2 sensors connected (for example in auto or fixed
setpoint mode), the device records a ppO2 sample with all three values
set to zero. Such samples are now ignored, as if there was no ppO2
sample present.

Reported-by: Anton Lundin <glance@acc.umu.se>
2015-09-10 09:25:06 +02:00
Jef Driesen
c72bdfe4e4 Add support for logging I/O operations.
The Atomics Cobalt backend uses libusb directly, without going through
an internal I/O layer that support logging. Therefore the logging needs
to be done in the backend itself.
2015-09-07 22:51:44 +02:00
Jef Driesen
55afe711f7 Fix the layout for the Oceanic Pro Plus 3.
The logbook ringbuffer starts at address 0x03E0 instead of 0x240. Since
none of the other models uses the same address, a completely new layout
structure is necessary.
2015-08-29 09:16:49 +02:00
Jef Driesen
3ff890b3e2 Improve the detection of unused tanks.
The begin/end pressure for unused tanks is normally zero. But I noticed
that in some cases both pressure values are stored as 0xFFFF. Since that
corresponds to a pressure of 511.99 bar, this is most likely some
special magic value, and not a valid pressure.

Tanks where either the begin or end pressure is 0xFFFF are now ignored
too.
2015-08-28 07:28:26 +02:00
Jef Driesen
5381714d08 Fix a bug in the tank id.
Due to a bitshift with the wrong number of bits, the tank id was always
zero for the Uwatec trimix firmware.
2015-08-20 09:08:56 +02:00
Jef Driesen
922d219bdc Add support for the tank field. 2015-08-10 13:10:44 +02:00
Jef Driesen
2fafcc7ae2 Disable all gas mixes in gauge/freedive mode. 2015-08-06 12:00:10 +02:00
Jef Driesen
04ffc894c9 Add support for ppO2 samples.
When the PPO2 sample was introduced, we didn't take into account the
fact that rebreathers usually support multiple O2 sensors. The HW OSTC
supports for example three sensors. In order to support multiple values,
without having to introduce a new data structure with an additional
sensor id field, we simply relax the assumption of allowing only one
DC_SAMPLE_PPO2 value per sample. Applications that are not prepared for
multiple values, will automatically use only one of them (probably the
last one).
2015-08-06 08:50:14 +02:00
Jef Driesen
a8f06c5c3c Add support for the new compact logbook headers.
With firmware version 1.84 (beta), a more compact logbook header is
introduced. Due to their smaller size (16 vs 256 bytes), the total
amount of data that needs to be transferred is much smaller (4K vs 64K).
Therefore, downloading these compact headers is roughly 16 times faster
then downloading the full headers.

For backwards compatibility with older firmware versions, there is an
automatic fallback to the full logbook headers.
2015-08-02 21:22:32 +02:00
Jef Driesen
98a7b86dcf Merge branch 'petrel' 2015-07-15 14:36:55 +02:00
Jef Driesen
0d04ad58a3 Add support for setpoint samples.
The setpoint samples are only enabled for closed circuit dives.
2015-07-15 14:36:30 +02:00
Jef Driesen
1a8e757daf Add support for the dive mode.
The Shearwaters store the current dive mode for each sample, and not one
single value for each dive. Therfore we need to process all samples. If
there is at least one sample marked as closed circuit, we classify the
dive as a closed circuit dive. Otherwise we default to open circuit.
2015-07-15 14:36:30 +02:00
Jef Driesen
af3b38d6f4 Cache the sample and header/footer size. 2015-07-15 14:36:30 +02:00
Jef Driesen
73ae03a4c0 Merge branch 'atom2' 2015-07-14 22:46:47 +02:00
Jef Driesen
4795e1b6ce Prevent a zero length memory allocation.
In theory this shouldn't be possible, but it doesn't hurt to check the
length explicitely.
2015-07-14 22:46:32 +02:00
Jef Driesen
76bd9783d4 Add an exception for devices without a logbook ringbuffer.
For devices without a logbook ringbuffer, such as the Oceanic Veo 1.0
and the Aeris XR-1 NX, the ringbuffer begin and end are identical. In
this case, the changes in the previous commit will always result in a
fatal error due to an invalid ringbuffer pointer. To avoid the error, we
exit before trying to use the pointers.
2015-07-14 22:46:32 +02:00
Jef Driesen
cfc1a68b0d Handle invalid logbook pointers as a fatal error.
Until now, an invalid logbook pointer was silently ignored and handled
as an empty ringbuffer. But this hides real errors, which is worse than
failing if no dives are present. Trying to download dives from an empty
device should be a rather uncommon scenario anyway.
2015-07-14 22:46:31 +02:00
Jef Driesen
55eaadac0c Merge branch 'uwatec' 2015-07-14 22:01:20 +02:00
Jef Driesen
f8d25fc49f Remove the event bytes from the vendor sample.
Now that we are able to parse the event bytes properly, there is no need
to pass the raw event bytes to the application.

In the current implementation, the vendor event was broken for devices
with multiple event bytes anyway. Because we deliver all event bytes at
once, the application doesn't know which bytes contain a valid value
(originating from the profile data) or just a dummy zero value.
2015-07-11 09:12:43 +02:00
Jef Driesen
efe7e52bbe Add support for parsing the event bytes.
Right now only gas switch and bookmark events are supported, because
none of the other uwatec events can easily be mapped onto the existing
libdivecomputer events. But the basic infrastructure for supporting more
events is in place now.
2015-07-10 10:58:05 +02:00
Jef Driesen
0158739bcf Use the static libgcc option only for Windows.
For obvious reasons, the -static-libgcc linker option is not supported
by non gcc compilers, like clang. Since we only need this option when
building Windows DLL's, we can easily avoid the problem with a
conditional on the mingw compiler.
2015-07-10 09:01:37 +02:00
Jef Driesen
b7c3582604 Fix the temperature for the Aeris Manta.
The Aeris Manta does not store the temperature as a delta value, but as
an absolute value (at offset 6).
2015-07-06 15:00:22 +02:00
Jef Driesen
37c00ce4f7 Add support for the Shearwater Petrel 2.
The Shearwater Petrel 2 uses exactly the same communication protocol as
the original Petrel. Therefore the new model has always been supported
out, and we only need to add the new model to the list of supported
devices.
2015-07-06 11:27:06 +02:00
Jef Driesen
73c6d03071 Merge branch 'uwatec' 2015-07-05 15:21:54 +02:00
Jef Driesen
701b93d865 Add support for the Galileo Trimix.
For the trimix version, the gasmix and tank information is no longer
stored in the header. It's now stored in a special sample at the end of
the dive.
2015-07-05 15:21:37 +02:00
Jef Driesen
7f3cea691d Use a fixed id for the uwatec deco mix.
The id of the uwatec deco mix is always 2, even for devices which
support maximum two gas mixes. Strictly speaking, this change is more
correct than commit 4fd825cdac341a2d4a1366c6deb7d4a71bbdf94d, allthough
in practice they are equivalent.
2015-07-05 15:21:37 +02:00
Jef Driesen
82c1a55a13 Fix the gas switches for galileo devices.
The bitmask for the gas mix bits was wrong. With the new mask we also no
longer have to disable the alarm based gas switches for the Meridian and
Chromis.
2015-07-05 15:21:37 +02:00
Jef Driesen
b17f432635 Fix the logic to skip disabled gas mixes.
Originally I assumed it's not possible to enable a gas mix if the
previous gas mix has already been disabled. However, this assumption
turns out to be wrong.  For devices with support for 3 gas mixes, it's
possible to enable only the first and the third gas mix, and leave the
second gas mix disabled.

This is fixed by checking all gas mixes, instead of aborting once the
first disabled gas mix has been found. Due to this change the uwatec gas
mix id's are no longer sequential and need to remapped to the
corresponding internal array index.
2015-07-05 15:21:37 +02:00
Jef Driesen
5629efad94 Merge branch 'eonsteel' 2015-07-05 11:37:52 +02:00
Linus Torvalds
90a19dd154 EON Steel: don't report airtime remaining as a libdivecomputer event
It looks like the SAMPLE_EVENT_AIRTIME is actually meant for just
airtime warnings (as in the dive computer warning about low air).

If we ever care, I think we'd need to add a new interface for this.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 11:33:49 +02:00
Linus Torvalds
a16f8ec470 EON Steel: fix up missing gastime/ventilation parsing
Now that I actually have dives with the new format and with air
integration, I could test it all out and noticed some missing pieces.

This adds parsing for gastime and ventilation events (although we don't
*do* anything with the ventilation data, I have no idea what the number
means).

Also, this fixes an annoying warning message problem, which caused these
missing events to cause a SIGSEGV rather than just a bening warning.
Stupid bug, and only went unnoticed because libdivecomputer isn't built
with format string warnings.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-05 11:33:49 +02:00
Linus Torvalds
edbdea0472 EON Steel: convert to dynamic sample parsing
This gets rid of the fixed sample indexes and the hardcoded grouping
code, and replaces them with proper parsing of the type descriptions.

This should mean that the new Suunto firmware v1.1.15 is now fully
supported by libdivecomputer.

There are still parts of the event description that we should really
parse better, notably the 'enum' descriptions of what the different
enumerated types mean, because it looks like those will change too.  But
that is not nearly as important as getting the basic infrastructure done
for the core sample types.

Almost accidentally, this also ends up now parsing the compass heading
event.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-07-05 11:33:49 +02:00
Linus Torvalds
af3e099c55 EON Steel: start moving away from "fixed" fields
I was initially fooled into thinking that the field type numbers have
some meaning: the types didn't change if the upper byte of the type
number was zero.  So I assumed that meant "fixed".

But the most recent firmware update made clear that no, they aren't
fixed, and the upper byte of the type must be some other thing.

This moves some more of the parsing over to comparing the strings,
rather than looking at the type index.  It still leaves the sample data
alone, and I really want to do something more efficient than comparing
the type descriptor string for that, but at least the dive header fields
are now just comparing strings.

The actual marshalling that Suunto uses also describes the encoding, and
it's all ignoring that for now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-07-05 11:33:35 +02:00
Linus Torvalds
a701cc9309 EON Steel: empty descriptor lines are ok
Suunto's new v1.1.15 firmware ends up terminating some final descriptor
lines with a newline, rather than just using newlines as separators.  So
the last newline may not be followed by further data, but simple be the
end of the string.  Accept that case.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-07-04 08:44:54 +02:00
Linus Torvalds
bdae428639 Suunto EON Steel: populate dive surface pressure
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 08:44:54 +02:00
Linus Torvalds
9eef4d6cec suunto eon steel: clean up size limits and error reporting
This is some small cleanup after the whole reply size rewrite.  It
further improves on the error log reporting a bit, and it undoes the
"read exact size" thing introduced in "suunto eon steel: fix file
reading special case", because it is no longer necessary.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 08:44:54 +02:00
Linus Torvalds
e73dcdacae suunto eon steel: be more explicit about transfer sizes
When reading data from the EON Steel, we'd generally continue reading
until we saw that a response was done by seeing a packet that wasn't
full.

That broke for the case of the data boundary matching the packet
boundary, fixed by the commit "suunto eon steel: fix file reading
special case".

However, that commit only fixed it for the case of reading a file, where
the result has a size that is known up-front.  And most other situations
really don't matter, because the result size is fixed and fits in a
single packet, so it all works.

However, there are still a few cases that could trigger the problem,
notably reading the directory contents.

So change the send_receive() logic to actually read the expected size
from the receive header in the first packet of the reply.  This means
that we need to re-organize the packet reception code a bit, but the end
result is that we are much more careful about data sizes,

This also changes the packet logging to be much more readable, by
logging just the actual data, and not the (uninteresting) per-packet
header, or the stale data at the end of the packet.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 08:44:54 +02:00
Linus Torvalds
8e3cb0542f suunto eon steel: fix file reading special case
The "receive_data()" function would continue to try to read packets as
long as the previous packet was full-sized, but with just the right size
of file and the right chunking, the file might end at a packet boundary.
Then receive_data() would try to read more data, which fails - there are
no more packets, despite the last packet being full.

This never triggered for me, but Robert Helling forwarded a data dump of
a filure to read a dive due to this.

Since I don't trigger this case, I can't really test it, but I did check
that the new "stop early" logic works for me (ie never triggers ;).

Reported-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-04 08:44:54 +02:00