906 Commits

Author SHA1 Message Date
Jef Driesen
abe2eab976 Fix the date/time for the Oceanic Pro Plus 3.
The day is stored as a binary value, not a BCD encoded value.
2014-10-25 21:21:43 +02:00
Jef Driesen
8853a1ccd4 Associate the pressure samples with the primary tank.
The primary tank, which is the tank connected to the hose and thus the
tank pressure sensor, it not necessary the first tank. The correct tank
index can be found by searching the array for a gas mix with a sensor id
equal to one.
2014-10-10 21:28:24 +02:00
Jef Driesen
9db9e970cf Convert the gasmix id into an array index.
The gasmix value in the sample data is the id of the gasmix. Depending
how the user manipulated the gasmix settings, this id is not necessary
identical to the index into the gasmix array.  The array index can be
found by searching the array for a mix with the correct id.
2014-10-10 21:28:24 +02:00
Jef Driesen
8edc765e6b Add some more error messages. 2014-10-10 21:27:15 +02:00
Jef Driesen
693bfa3916 Fix the Tusa Zen header size and pressure.
For the Tusa Zen, the header is 16 bytes smaller. With this change, the
gasmixes and the intial temperature are now parsed correctly.

The tank pressure samples have also been disabled manually, because this
is a non-air integrated model that doesn't seem to set the initial tank
pressure to the magic value 10000.
2014-09-14 22:09:48 +02:00
Jef Driesen
5f765f9143 Add support for the Subgear XP-3G. 2014-08-26 22:09:47 +02:00
Jef Driesen
e79bd02f0a Fix a buffer overflow.
The 6 byte logbook entry gets prepended to the profile data. We need to
take this into account when allocating the memory buffer. Under normal
circumstances this shouldn't be a problem, because a single dive is
usually much smaller than the profile ringbuffer. But it's better to be
on the safe side.
2014-08-26 22:08:41 +02:00
Jef Driesen
cde70334b0 Initialize the fingerprint before use.
The fingerprint is used unconditionally, regardless of whether it's
explicitly set by the application or not. Therefore it needs to be
initialized properly.
2014-08-26 22:07:59 +02:00
Jef Driesen
6845d9b77c Fix the Mares Puck 2 memory layout descriptor.
The Mares Puck 2 uses the same memory layout as the Nemo Wide 2. See
commit 322227df7f65da8b4a962f3513e0a10b89cbe29d for more details.
2014-08-21 23:41:20 +02:00
Jef Driesen
84d997fac6 Fix a build error.
Commit 7a851ccb1b9ed9b8906721cb1872b96b35185883 accidentally broke the
build due to a missing line.
2014-08-16 22:46:53 +02:00
Jef Driesen
549207a48b Add suport for the OSTC Sport variant.
Although the OSTC Sport uses bluetooth communication, the new model
remains fully compatible with the OSTC3, because it provides a virtual
serial port interface. As usual, the new model can be detected based on
the serial number.
2014-08-16 17:39:12 +02:00
Jef Driesen
b12d5acb86 Merge branch 'iconhd' 2014-08-14 12:00:03 +02:00
Jef Driesen
7a851ccb1b Add some extra error messages. 2014-08-14 10:20:23 +02:00
Jef Driesen
b0874ea4d9 Disable gas mixes and events in gauge mode.
For a dive in gauge mode, the gas mixes defined in the header should be
ignored, and no gas change event should be emitted. This is done by
hardcoding the number of gas mixes to zero.
2014-08-14 09:52:57 +02:00
Jef Driesen
4f2d71ce49 Cache the parser data internally.
The code to find the offset to the footer and parse the gas mix data is
duplicated in multiple places. Move this code to a single place, and
cache the data in the parser instead.
2014-08-13 16:23:22 +02:00
Jef Driesen
c2f86a7806 Ignore disabled gas mixes.
Gas mixes that have been disabled are stored as a mix with 0% oxygen and
0% helium. This is clearly an invalid gas mix, and it makes no sense to
return it back to the application.
2014-08-09 17:19:36 +02:00
Jef Driesen
ed2b9d34d5 Fix the dive mode detection for the Mares Nemo Air.
For the Nemo Air, a dive mode with the value 2 indicates gauge mode
instead of freedive mode. With this change, all models from the puck
family now use the same values.
2014-08-03 15:49:16 +02:00
Jef Driesen
5826257a79 Use symbolic constants for the model numbers. 2014-08-03 15:03:08 +02:00
Jef Driesen
eb036357a6 Ignore excess samples with the same timestamp.
With a time based sample interval, the maximum number of samples for a
single timestamp should be constant. However in practice some devices
occasionally store one or more additional samples with the same
timestamp.

Ignoring those excess samples, allows the parser to proceed, while still
preserving the strict time based interval for the application.
2014-07-10 12:40:10 +02:00
Jef Driesen
77d53813bd Remove the device specific example applications.
These device specific applications became obsolete long time ago with
the introduction of the universal application.
2014-07-02 17:06:27 +02:00
Venkatesh Shukla
33710423ac Add an option to disable the example applications.
The example applications may not always be needed. An option to disable
them might be useful.

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
2014-07-02 16:26:39 +02:00
Jef Driesen
6433a45bbc Fix the date/time for the Aeris Elite T3.
Commit d414da70a42afca0096e0402a426c4ac8d2a2881 added support for a
second Aeris Elite T3 variant. But the parser wasn't updated to take
into account this second model number.
2014-06-25 08:44:36 +02:00
Jef Driesen
368c138858 Fix the gas mixes for a few models.
For the Aeris Manta and Sherwood Insight, the header size should be 16
bytes smaller. Due to this mistake not only two samples were missing,
but also the byte offset for the gas mixes were wrong. This resulted in
invalid gas mixes, with oxygen percentages exceeding 100%.
2014-06-25 08:44:27 +02:00
Jef Driesen
48e73babd6 Fix the temperature for the Sherwood Wisdom 2.
The sign bit should be reversed for this model.
2014-06-20 22:22:41 +02:00
Jef Driesen
f8081f1e1f Merge branch 'gasmix' 2014-06-19 09:01:14 +02:00
Jef Driesen
f20f28e9d0 Ignore disabled gas mixes.
For the older models, gas mixes are disabled by setting their oxygen
percentage byte to 0x00 or 0xFF. Trying to parse such a byte as a valid
percentage results in an invalid gas mix.

Because the device doesn't allow you to enable a gas mix if the previous
gas mix has already been disabled, we can simply stop parsing the gas
mixes once the first disabled gas mix has been found.
2014-06-19 08:58:51 +02:00
Jef Driesen
86e9c3dfd3 Cache the initial gas mix.
The gas mode should not only be taken into account for parsing the gas
mix definitions, but also for the initial gas mix. Because the logic
needs to be kept in sync, it's convenient to have all related code in a
single place, and cache the value.
2014-06-17 21:05:23 +02:00
Jef Driesen
28135bc57a Apply the gas mode immediately.
Because the gas mode takes precedence over the individual gas mix
definitions, we can simplify the code by taking the gas mode into
account immediately when parsing the gas mixes.
2014-06-17 21:05:23 +02:00
Jef Driesen
e0e6460372 Merge branch 'dx' 2014-06-17 21:04:50 +02:00
Jef Driesen
bb2b64f5d7 Fix the length of the Suunto DX gas change event.
The Suunto DX uses 5 bytes for the 0x06 gas change event.
2014-06-17 21:03:55 +02:00
Jef Driesen
8a5bfc390d Remove the percentage variable.
There is already another variable for the O2 percentage, so re-use that
one instead.
2014-06-17 21:03:55 +02:00
Jef Driesen
e263a1c336 Improve the warning and error messages. 2014-06-17 21:03:55 +02:00
Jef Driesen
ffd1d1c8b6 Disable the gas mixes in gauge mode. 2014-06-12 08:31:19 +02:00
Cristian Ionescu-Idbohrn
1d6c933415 Another gitignore update.
Signed-off-by: Cristian Ionescu-Idbohrn <cristian.ionescu-idbohrn@axis.com>
2014-06-11 15:25:24 +02:00
Jef Driesen
8eebc0abd8 Add support for the Beuchat Voyager 2G. 2014-06-07 10:08:04 +02:00
Jef Driesen
20c874b267 Use higher resolution timestamps on Windows.
In commit 886884ab606def1183d99eca7dec8affefee635e, the custom log
function in the example applications has already been modified to use
high resolution timestamps. But I forgot about the built-in default log
function. So this is basically the same change, but now applied to the
built-in log function.
2014-05-28 15:41:21 +02:00
Jef Driesen
2e71075c5b Merge branch 'termios' 2014-05-28 15:40:41 +02:00
Jef Driesen
197b9f0942 Remove the extra check of the termios structure.
The extra memcmp check after the tcsetattr call is intended to verify
whether all the changes to the termios structure have been applied
correctly.

But for pty's, some of the termios settings make no sense at all, and
therefore the Linux kernel always does:

    tty->termios.c_cflag &= ~(CSIZE | PARENB);
    tty->termios.c_cflag |= (CS8 | CREAD);

Thus, instead of ignoring such nonsense termios settings, the kernel
changes the termios structure to reflect what pty's actually do. The
consequence is that these settings will not stick, and cause the memcmp
check to fail.

An example where this affects libdivecomputer, are the two backends that
require odd or even parity (e.g. vyper and iconhd). Here, the kernel
will clear the PARENB flag, and thus cause the memcmp check to fail.

Since this check appears to causes more trouble than it solves, let's
just remove it completely!
2014-05-28 11:11:35 +02:00
Jef Driesen
5f1a18653d Initialize the termios structure.
The previous commit exposed another issue. The termios structure may
contain padding bytes. Because the content of those padding bytes is
unspecified, they may contain some random data, which causes the memcmp
to fail.

Explicitly initializing the termios structure with memset, will also set
the padding bytes to zero.
2014-05-28 11:10:23 +02:00
Venkatesh Shukla
3001dda198 Minor error in serial_configure
Due to a minor mistake, only the first byte was being checked for
equality. Fixed it by changing position of parenthesis.

Signed-off-by: Venkatesh Shukla <venkatesh.shukla.eee11@iitbhu.ac.in>
2014-05-20 21:48:57 +02:00
Jef Driesen
48924123a6 Fix a typo in the profile ringbuffer start address.
The profile ringbuffer is supposed to be located after the logbook
ringbuffer, but due a silly typo they did overlap with 256 bytes.
2014-05-19 22:57:49 +02:00
Jef Driesen
654a909936 Fix the Mares Puck Pro memory layout descriptor.
The Mares Puck Pro uses the same memory layout as the Nemo Wide 2. See
commit 322227df7f65da8b4a962f3513e0a10b89cbe29d for more details.
2014-05-19 08:40:10 +02:00
Jef Driesen
1872b71dad Add support for ascent rate warnings.
The Cressi Leonardo does store an indicator for the ascent rate (e.g.
the number of arrows) in the upper two bits. This results in 4 possible
values, ranging from 0 to 3, with the following interpretation:

    0.0 -  3.9 m/min  No signal
    4.0 -  7.9 m/min  1 Arrow
    8.0 - 11.9 m/min  2 Arrows
   12.0+       m/min  3 Arrows (with STOP icon)

Reported-By: Nick Shore <support@mac-dive.com>
2014-05-13 10:35:06 +02:00
Jef Driesen
61e9847196 Merge branch 'ostc' 2014-05-06 22:16:59 +02:00
Jef Driesen
b7a5394e73 Add support for the new OSTC3 bailout event.
With the exception of the different event mask (single byte 0x80 vs two
byte 0x0100), the OSTC3 bailout event is identical to the OSTC2 variant.
Just as before, the new bailout event is reported to the application as
a normal gas change event.
2014-05-06 11:25:46 +02:00
Jef Driesen
4db8535e39 Use the extended sample length stored in the data.
Currently, the buffer overflow checks take into account the size of the
entire dive. But since the length of the extended sample is stored in
the data, we can actually check for overflows in each sample. The main
benefit is that errors will be caught much earlier now.

An additional advantage is that we can now easily skip any remaining
sample bytes. Normally such bytes are not present, unless a firmware
update introduces a new feature which our parser doesn't support yet.
2014-05-06 11:25:46 +02:00
Jef Driesen
5abad6e568 Add more error messages.
This makes debugging easier, because the error messages immediately
reveal where the problem is located, without needing a debugger.
2014-05-06 09:07:13 +02:00
Jef Driesen
466fb0ff6b Add more buffer overflow checks.
There are a few places left, where the contents of the buffer is
accessed without first inspecting the available length.
2014-05-06 09:03:26 +02:00
Jef Driesen
322227df7f Fix the Mares Nemo Wide 2 memory layout descriptor.
The Mares Nemo Wide 2 appears to have a slightly larger profile
ringbuffer, which extends to the end of the internal memory. It remains
to be seen whether this is also true for some of the other models. The
Mares Matrix is currently the only model where this is definitely not
the case.
2014-04-22 14:29:58 +02:00
Jef Driesen
b4cc491aee Add support for the Aeris A300. 2014-04-22 14:29:58 +02:00