786 Commits

Author SHA1 Message Date
Anton Lundin
543ddca8a2 Add code to write rom of the OSTC3
This is how you transfer a new firmware to the OSTC3.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
6322e96268 Add function to read the rom from the OSTC3
This is necessary to verify that the memory written got transfered
correctly.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
5c71ff34c4 Add a function to erase the memory of the OSTC3
This is the fist step in the firmware upgrade process.

This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
08dda98c29 Add utility functions to convert uints to bytes
Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
1d8337c570 Add a helper to put the OSTC3 into servicemode
This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
d8f11810e1 Lift the OSTC3 INIT out of open
This lifts the OSTC3 INIT command out from the open function and does
that separately. This is refactoring to be able to enter service mode so
we can access service mode commands.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01:00
Anton Lundin
b1c12b597b Add code to read and decrypt OSTC3 firmware files
This code is inspired by JeanDo ostc-companion.

Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 14:52:12 +01:00
Anton Lundin
954cae1a0e Workaround msvc lack of a stdint.h
Suggested-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 14:52:12 +01:00
Anton Lundin
5820ac01e3 Port TinyAES-128 to be thread safe.
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 14:52:12 +01:00
Anton Lundin
52bc5ab7a0 Import Tiny AES128
This imports Tiny AES128 from https://github.com/kokke/tiny-AES128-C for
use in the decoding of OSTC3 firmwares.

This aes-code is released into the public domain.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 14:52:12 +01:00
Janice
4b61434587 Also cache the number of mixes and the mix values
At least one dive computer in the Suunto Vyper family, the Vytec DS, is
capable of recording gas mix switches, and therefore supports more than
one mix. When going through the dive profile caching process, also look
for gas changes and record how many mixes were used in the dive. Mix 1
is always the main tank and it’s O2 value can be found in the dive
header, but the other tank O2 values are not available ahead of time. By
reviewing the dive profile ahead of time, the entire list of mixes can
be returned to the application at the beginning of the dive as per
usual.
2014-12-04 23:24:54 +01:00
Jef Driesen
3bf73253bc Cache the parser data internally.
The code to calculate parameters like maximum depth and divetime is
duplicated in multiple places. Move this code to a single place, and
cache the data in the parser instead.
2014-12-03 19:35:50 +01:00
Jef Driesen
134da18190 Fix the temperature for the Sherwood Amphos.
The sign bit is stored at a different offset.
2014-11-30 21:02:13 +01:00
Jef Driesen
598377ec44 Add support for the Citizen Hyper Aqualand. 2014-11-30 15:30:16 +01:00
Jef Driesen
21f3dbcb04 Add a default case to the switch statement.
This is only the silence the "enumeration value not handled in switch"
compiler warning. There is already a check earlier on to take care of
unsupported fields, but the default case is a good practice anyway.
2014-11-24 11:57:23 +01:00
Jef Driesen
0ed5e6d653 Fix another memory leak.
The array with type descriptors is populated with dynamically allocated
strings, but they are never freed anywhere. To be able to free those
strings easily, they are now initialized with NULL pointers instead of
zero length strings.
2014-11-24 11:57:23 +01:00
Jef Driesen
d1121d174c Fix a few memory leaks. 2014-11-24 11:37:24 +01:00
Jef Driesen
6df4f00822 Fix a NULL pointer dereference. 2014-11-24 11:37:24 +01:00
Jef Driesen
0b0acf7336 Use the non-standard _snprintf() function for msvc. 2014-11-24 11:37:24 +01:00
Jef Driesen
dbcaa6946a Add explicit casts for the msvc C++ compiler. 2014-11-24 11:37:24 +01:00
Jef Driesen
f228a5f9fc Replace string literals with arrays.
This avoids some more compiler warnings regarding incompatible pointer
types (e.g. signed vs unsigned char pointers). Arrays have the
additional advantage of the sizeof operator. This eliminates an
unnecessary strlen() call, and the strcpy() call can be replaced with
memcpy().
2014-11-24 11:37:24 +01:00
Jef Driesen
d5933d59fb Replace zero length strings with NULL pointers.
This avoids some compiler warnings. The type of the string literal is a
const char pointer, while the send_cmd() function expects an unsigned
char pointer.
2014-11-24 11:37:24 +01:00
Jef Driesen
4120b2f0e9 Replace void pointers with unsigned char pointers.
Since we're dealing with byte arrays, there's no need to use void
pointers. Using unsigned char pointers also eliminates some compiler
warnings for pointer arithmetic on void pointers.
2014-11-24 11:37:24 +01:00
Jef Driesen
e8c2e87919 Remove the custom logging functions.
There is no need for custom logging functions, because libdivecomputer
already has an extensive logging infrastructure, featuring conditional
compilation, multiple loglevels, customization by the application, etc.
2014-11-24 11:37:24 +01:00
Jef Driesen
3368294018 Don't terminate the application on error.
Terminating the application on error, by calling exit, is not
appropriate in a library. An error code should be returned instead.
2014-11-24 11:37:24 +01:00
Jef Driesen
1fa054b409 Use the libusb autodetach functionality only if available.
The libusb autodetach kernel driver functionality is only available in
recent versions.
2014-11-24 11:37:24 +01:00
Jef Driesen
6bc6e58d3b Fix a redefinition warning for the ERROR macro.
See commit 113d2e4706698f7086e5499282ec958aa2de044f for more details.
2014-11-24 11:37:24 +01:00
Jef Driesen
686500d51b Follow the libdivecomputer naming conventions.
All entry point functions (e.g. public functions or functions called
through the vtable) use the backend name as the prefix. The same applies
to the main device and parser structures.
2014-11-24 11:37:24 +01:00
Linus Torvalds
5c967f3382 Suunto EON Steel: support downloading of core dive profile data
Basic Suunto EON Steel downloading copied from my test application.
This parses all the core dive data, including sample data (time, depth,
cylinder pressure, deco information etc).

The deco information returns ceiling and TTS rather than ceiling and
"time at ceiling", because that's what the dive computer has, and I
don't see any other way to return the information.

We don't report any events yet, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-11-24 11:37:23 +01:00
Jef Driesen
b2bc231cb4 Convert imperial tank volume to the metric system.
There are two different ways to specify the volume of a tank. In the
metric system, the tank volume is specified as the water capacity, while
in the imperial system the tank volume is specified as the air capacity
at the surface (1 ATM) when the tank is filled at its working pressure.

To avoid mistakes, the tank volume is now always returned as the metric
volume. For imperial tanks, the tank volume is converted to the metric
representation.
2014-11-13 13:13:07 +01:00
Janice
71fe683922 Don't look for tank pressure information from a GEO 2014-11-10 13:05:33 +01:00
Dirk Hohndel
5e88cf7494 Add missing break in Cobalt support for divemode
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-09 09:59:20 +01:00
Jef Driesen
4a16327322 Fix the tank working pressure for the Cobalt.
The difference between CUFT@PSI and CUFT@BAR is only for the Cobalt user
interface, to allow the user to enter the tank volume independent of the
units configured in the main preferences. Internally the working
pressure is always stored in psi.
2014-11-09 09:20:16 +01:00
Jef Driesen
52a9dc3947 Add support for the Mares Airlab.
The Mares Airlab is actually the same device as the Darwin Air.
2014-11-07 22:12:59 +01:00
Jef Driesen
88159c6fe4 Implement the dive mode for several devices.
The new dive mode field is now supported by devices from these
manufacturers:

 * Atomic Aquatics
 * Heinrichs Weikamp
 * Mares
 * Reefnet
 * Suunto
2014-11-07 22:12:05 +01:00
Jef Driesen
c95ab19e6a Use symbolic constants for the dive mode. 2014-11-07 22:04:16 +01:00
Jef Driesen
25411672dc Implement tank support for the Mares Darwin Air. 2014-11-07 22:00:07 +01:00
Jef Driesen
11cafbaf5f Implement tank support for the Atomic Cobalt. 2014-11-07 22:00:07 +01:00
Jef Driesen
52cac91b18 Implement the temperature support for several devices.
The new temperature fields are now supported by devices from these
manufacturers:

 * Atomic Aquatics
 * Heinrichs Weikamp
 * Mares
 * Suunto
 * Uwatec
2014-11-07 21:58:49 +01:00
Jef Driesen
693a452250 Extend temperature with surface, min and max values. 2014-11-07 21:58:49 +01:00
Calle Gunnarsson
a4e5d4234c Cressi Leonardo now reports temperature from dive header
Signed-off-by: Calle Gunnarsson <calle.gunnarsson@gmail.com>
2014-11-07 21:58:49 +01:00
Jef Driesen
60665ec633 Disable exclusive access mode during close.
When closing the slave side of a pseudo terminal, the exclusive access
mode will persists on the master side. The result is that re-opening the
slave side will fail with EBUSY, unless the process has root priviliges.
To workaround this problem, we already introduced an option that enables
better compatibility with pseudo terminals. See commmit
fab606b00a44ea2114a4029ad09b70c66c3049f7 for details.

In my development environment, I always have this option enabled. But
occasionally I also need to test release builds. And then I usually end
up with inaccessible pty's again, because the pty support is disabled by
default for release build.

This problem can easily be avoided by disabling the exclusive access
mode, just before closing the file descriptor.
2014-11-07 09:07:41 +01:00
Dirk Hohndel
d2eacc5c01 Fix temperature parsing for Sherwood Wisdom 3
Adds the new model and treats it like a Wisdom 2 (and many other, similar
versions of the Oceanic Atom2 style dive computers).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-30 10:03:11 +01:00
Janice McLaughlin
69fec57ed7 Fix the gas mixes for the Aeris A300AI.
The Aeris A300AI supports 4 instead of 3 gas mixes. The offset where the
gas mixes are stored was wrong too.
2014-10-28 09:14:25 +01:00
Jef Driesen
1d2ebd7af1 Fix the header size for the Oceanic VT4 and VT4.1.
This change was already present in the oceanic_atom2_parser_get_field()
function, but not in the oceanic_atom2_parser_samples_foreach()
function. These two should always be kept in sync.

This fixes a bug in the tank pressure detection.
2014-10-28 09:07:18 +01:00
Jef Driesen
853477b3b1 Add support for the Aeris F11.
Most of the changes needed for the F11 are the standard model specific
tweaks. But the F11 also has another interesting "feature". If you try
to download a full memory dump using the standard B1 read command, then
the data starts to repeat after the first 64K. It seems that somehow,
the B1 command can only address the first 64K of the memory. To avoid
this problem, the newer B4 read command needs to be used instead.

This might be a firmware bug, or maybe internally they store the address
in a 12bit variable, which causes the upper bits to get lost? That would
explain the repeating data.
2014-10-27 22:02:04 +01:00
Jef Driesen
a1ff11e08e Cache the last page to reduce the number of I/O operations.
In bigpage mode, we always read large pages, regardless of the amount of
bytes requested by the caller. Excess bytes are simply discarded. This
is inefficient because the same large page will be downloaded multiple
times, when requesting more than one 16 byte page from the same large
page. By caching the pages internally, we can greatly reduce the amount
of I/O operations.

In practice, applications and also libdivecomputer's internal algorithm
for downloading the dives will typically request contiguous pages, so we
only need to cache the last page.

This implementation is based on ideas and code contributed by Dirk
Hohndel.
2014-10-27 12:24:18 +01:00
Dirk Hohndel
0bcee519e0 Aeris A300CS: detect the number of cylinders used
The A300CS actually tells us how many of the cylinders it considers "in
use".

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 12:24:18 +01:00
Dirk Hohndel
7a108f555b Aeris A300CS: add reporting of water type (fresh/salt)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 12:24:18 +01:00
Dirk Hohndel
16fb1c1869 Aeris A300CS: add support for NDL / deco data
Encoded in every sample. The depth is in multiples of 10 feet which gives
somewhat odd metric stop depth - but rounding to full meters would take
care of that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-27 12:24:18 +01:00