1269 Commits

Author SHA1 Message Date
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
Jef Driesen
58f7235bb9 Update the symbols file. 2015-07-03 22:37:13 +02:00
Jef Driesen
98bd0d2d21 Update the msvc project file. 2015-07-03 22:37:13 +02:00
Jef Driesen
bd2b132d7f Avoid a run-time dependency on the libgcc dlls.
When compiling a 32bit dll with the mingw-w64 compiler, some 64bit
integer arithmetic operations are implemented using functions from
libgcc (e.g. __divdi3 and __moddi3 from libgcc_s_sjlj-1.dll). This
unexpected dependency is inconvenient for applications.

The run-time dependency can be avoid by linking statically.
2015-07-03 22:36:06 +02:00
Anton Lundin
ab92043dc3 Remove removed function from public header
reefnet_sensusultra_device_set_maxretries was killed off back in v0.3,
but was still lying around in the public header.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2015-06-26 09:59:24 +02:00
Jef Driesen
a72c03188d Use the correct layout for the Oceanic Geo.
At least one Oceanic Geo is unable to download the last memory page.
However, another device with an older firmware version (version 1D
instead of 2B), does not have this problem. So in theory the correct
layout depends on the firmware version.

But since the profile ringbuffer also appears to end at the address
0xFE00 instead of 0x10000, we'll never need to download that last page
in practice. Thus we can be lazy and simply use a single layout for all
firmware versions. The only drawback is that the last page might be
missing when downloading a full memory dump.
2015-06-16 23:00:07 +02:00
Jef Driesen
e7d142e5eb Fix the ringbuffer start address for the Aeris F10. 2015-06-16 23:00:07 +02:00
Jef Driesen
c647a27c27 Implement tank pressure samples for the Nemo Air.
The tank pressure is stored every third sample as a delta value.
2015-06-13 12:18:46 +02:00
Jef Driesen
bfd91a733c Implement the tank field for the Nemo and Puck Air. 2015-06-13 12:08:09 +02:00
Jef Driesen
e6f51ea302 Emit the devinfo event before using the fingerprint.
Applications are supposed to lookup the fingerprint when the devinfo
event is emitted. For the Uwatec Smart devices, the fingerprint is the
raw device timestamp. But because this timestamp was already used to
initialize the command before emitting the event, an outdated value
(typically the default value of zero) was used instead of the correct
one set by the application.
2015-06-02 09:46:08 +02:00
Jef Driesen
4dc727d507 Merge branch 'uwatec' 2015-05-21 16:28:24 +02:00
Jef Driesen
f720aa2fc8 Use the UTC offset of the device.
For devices with timezone support, use the UTC offset stored by the
device, instead of the current timezone of the host system.
2015-05-19 12:05:40 +02:00
Jef Driesen
74fcd11d2b Add support for the salinity field. 2015-05-19 12:05:40 +02:00
Jef Driesen
5ca1ef40c1 Adjust the depth for salt water dives.
The Uwatec dive computers report the depth based on fresh water. Salt
water dives need a correction to take into account the salinity. There
is only a fresh/salt water flag present in the data, but Uwatec appears
to assume a salinity factor of 1.025.
2015-05-19 12:05:40 +02:00
Jef Driesen
f59bad5260 Add support for the new tank fields. 2015-05-19 12:05:40 +02:00
Jef Driesen
50c8b46c96 Fix the size of the dive header.
The size of the dive header is one byte smaller: 0x32 instead of 0x33
bytes. Because we were expecting a larger packet, this bug caused the
downloading of the dive headers to fail. I'm surprised no one noticed
this mistake before.
2015-05-13 08:14:12 +02:00
Jef Driesen
568365397d Fix the CNS sample value.
The CNS value in the public api is reported as a fraction, and not a
percentage.
2015-05-13 08:13:59 +02:00
Jef Driesen
e810232a6d Add support for CNS samples. 2015-05-13 08:13:39 +02:00
Jef Driesen
d5eaa979d0 Convert the CNS value to a percentage. 2015-05-12 19:54:15 +02:00
Jef Driesen
4094f379ae Merge branch 'suunto' 2015-05-08 08:29:13 +02:00
Jef Driesen
106abe2dba Remove the temperature and pressure samples.
With the new temperature and pressure field, artificially injecting the
temperature and pressure info from the header into the samples is no
longer necessary. Applications will typically expect a real temperature
or pressure profile, and not a few discrete points.

The two surface samples (with zero depth) at the begin and end of the
dive are kept for now, to support events that occur at the surface.
2015-05-08 08:17:18 +02:00
Jef Driesen
7278a70afe Implement the tank and temperature fields. 2015-05-08 08:15:09 +02:00
Jef Driesen
5a61ffcc2f Use a variable for gauge mode.
This makes the code a little bit more readable, without needing any
comments.
2015-05-08 08:14:06 +02:00
Jef Driesen
e1f939c131 Move all caching code to a common function. 2015-05-05 21:15:51 +02:00
Jef Driesen
02e812f88b Apply the ghost event fix for the Suunto Solution.
I forgot to include the Suunto Solution part in the previous commit.

In theory the Suunto Solution (and Eon) can't be affected by the ghost
event bug. All possible events bytes are already exhausted, and
therefore unknown events are impossible. But applying the fix anyway
doesn't hurt and keeps the code consistent with the other backends.
2015-05-05 20:31:03 +02:00
Jef Driesen
23acddbe08 Eliminate ghost events caused by unknown events.
The newest Suunto models (e.g. D4i, D6i, D9tx and DX) support a few
additional events (type 0x15 and higher), which are not supported yet
because their interpretation isn't known.

Due to a nasty bug, these unkown events result in "ghost" events. When
such an unknown event is encountered, the sample type field isn't set
explicitely. Therefore it simply retains the value from the previous
sample, whatever that might be. If the previous sample happens to be an
event as well, then the unknown event will show up as a duplicate event.
But if the previous sample is not an event, then the resulting event
type is undefined.

This is fixed by always resetting the event type explicitely. Those
unknown events are also suppressed now and no longer delivered to the
application.

Allthough I haven't observed this bug with the Suunto Eon and Vyper,
they could be affected too.
2015-05-04 15:50:53 +02:00
Jef Driesen
ecd20ffb4c Merge branch 'ostc' 2015-05-01 11:31:07 +02:00
Jef Driesen
f24b93cd82 Parse the profile to retrieve the manual gas mixes.
The DC_FIELD_GASMIX api doesn't support the 6th manual gas very well.
Manual gas mixes are either not taken into account at all (OSTC3), or
only the last value is returned (OSTC2).

We now parse the profile data in order to retrieve all the manual gas
mixes too. Note that manual gas mixes are only included when they are
actively used during the dive. This is a small change in behaviour for
the OSTC2.

To simplify the implementation, there is an upper limit of 10 manual gas
mixes (or 15 gas mixes in total). This is an arbitrary choice, which
should be more than sufficient in practice. If it turns out to be too
small, we can always increase the number, or even make it truely
unlimited.
2015-05-01 11:29:35 +02:00
Jef Driesen
ac48210f4a Cache the fixed gas mixes too. 2015-05-01 11:29:35 +02:00
Jef Driesen
391de65d16 Cache the header data internally. 2015-05-01 11:29:35 +02:00
Jef Driesen
b832f4cf1b Cache the header and footer size internally. 2015-05-01 11:28:55 +02:00
Jef Driesen
8eba3cae3a Cache the gas mixes internally. 2015-05-01 11:28:20 +02:00
Anton Lundin
ad1c17b39d Dump function for the OSTC3
This adds a dump function for the ostc3 series computers. This function
dumps the whole external eprom, that contains the dive-headers and the
dive data.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2015-05-01 10:55:53 +02:00
Jef Driesen
c03c592a27 Merge branch 'iq700' 2015-04-29 23:06:12 +02:00
Jef Driesen
d7c89bbc39 Add support for the temperature field. 2015-04-22 08:27:41 +02:00
Jef Driesen
47874037ea Disable gas change events except for the intial mix.
For the IQ-700, the existing code for the active gas mix always results
in an out-of-range gas mix index. The index of the active gas mix is
probably stored in another bit. As a temporary workaround, we simply
assume the active gas mix is always the first gas mix. This should
already produce correct results for dives with only single gas mix.
2015-04-22 08:27:41 +02:00
Jef Driesen
311bc85645 Add support for the Tusa IQ-700.
The Tusa IQ-700 is very similar to the other Seiko based models. The
most important change is that due the smaller amount of memory (8K vs
32K), the logbook entries are only 1 byte large instead of two bytes.
2015-04-22 08:25:03 +02:00
Jef Driesen
f0974ed6bc Replace hardcoded constants with a layout descriptor. 2015-04-21 19:45:31 +02:00
Jef Driesen
9ae985a499 Fix the ringbuffer start address.
Currently the profile ringbuffer starts at the base address 0x4000, but
I believe the real start is one 0x20 byte page earlier, at 0x3FE0. I
have two reasons for this:

1. To locate the start of a dive, we always have to substract one page
from the pointers in the logbook ringbuffer. With the new base address,
they would point directly to the start of the dive, which makes a lot
more sense.

2. When comparing the divetime as stored in the header with the one
obtained by counting the number of samples, they always match except for
dives that span the ringbuffer wrap point. If those extra 0x20 bytes are
included, the counts do match again.

Unfortunately, this change breaks the assumption that the ringbuffer is
aligned to packet boundaries. As a workaround, we define a virtual
ringbuffer that is slightly larger than the actual ringbuffer, but
properly aligned. Data outside the real ringbuffer is downloaded and
then immediately dropped.
2015-04-21 19:45:31 +02:00
Jef Driesen
ad6ec1e7f5 Align all read operations to packet boundaries.
Packets have a fixed size of 0x80 bytes, while a single page is only
0x20 bytes long. Thus each read operation always returns 4 pages at
once. Now, if the end-of-profile pointer is not nicely aligned on a
packet boundary, then the download algorithm won't arrive exactly at the
start address of the ringbuffer, because the ringbuffer is properly
aligned. The consequence is that we won't even notice we reached the
ringbuffer boundary and happily continue reading outside the ringbuffer.
Oops!

This is fixed by aligning the end-of-profile pointer, which guarantees
that all read operations are now nicely aligned to packet boundaries.
2015-04-21 19:45:31 +02:00
Jef Driesen
c4233c091d Send the command and read the echo byte by byte.
When trying to send a command, the first attempt always fails. We
receive the echo, but no data packet. A second attempt usually works,
but we always get back the same data packet. That's cleary wrong.

Now, when comparing the data packets with those of the Tusa application,
I noticed something very interesting. When we request the first packet
(page 0x0000), we get:

  W: 520000
  R: 520000
  R: 00880124056202000250002890470824...19202720002000200020002000204145

The Tusa application also request this page, but the response is
completely different:

  W: 520000
  R: 520000
  R: 22182224222322092203220522112210...0000000000f021fc0000000000000045

The response we get is identical to the response that the Tusa
application gets for page 0x0052:

  W: 520052
  R: 520052
  R: 00880124056202000250002890470824...19202720002000200020002000204145

The only difference here is the echo of the command. But the echo should
be ignored, because it's generated by the pc interface, and not send by
the dive computer. This is easily verified by the fact that we always
receive an echo, even without a dive computer connected (e.g. only the
pc interface).

Notice how the command type (first byte) and page number (last byte) are
identical (0x52) for this request! I suspect that somehow the command
type ends up being interpreted as the page number. That would explain
why we're always getting the same response: as far as the device is
concerned we're always requesting page 0x52. This is probably also
related to the fact that the device doesn't respond after the first
request. It's not impossible that if the first command wasn't received
correctly and we resend the command, the device receives something that
contains parts of both attempts.

By sending the command and reading the echo byte by byte instead of all
at once, the above problem disappears.
2015-04-21 19:45:31 +02:00
Jef Driesen
edd777dbd3 Wait after changing the serial line settings.
Without the delay, the communication immediately fails. We receive the
command echo, but not the actual data packet. I suspect the device is
still be busy with the initialization and needs a bit more time before
it's ready to accept a request.
2015-04-21 19:44:01 +02:00