1159 Commits

Author SHA1 Message Date
Dirk Hohndel
290f2781ea Merge branch 'master' into Subsurface-branch v4.5.2 2015-11-06 22:24:56 -08:00
Jef Driesen
fb5f7ad971 Use the GCC printf format attribute.
This enables the compiler to check the arguments against a printf style
format string in all calls to the logging functions.
2015-11-06 07:52:27 +01:00
Jef Driesen
0a20eae342 Prefer the C99 identifier for the function name.
The GCC 5 compiler with -Wpedantic enabled generates warnings for the
non-standard predefined identifier __FUNCTION___. These warnings can be
avoided by using the C99 identifier __func__ instead.
2015-11-06 07:51:42 +01:00
Jef Driesen
84d67c5544 Add support for the new OSTC logbook format.
With the new logbook format version 0x24, the OSTC no longer stores the
date/time at the end of the dive, but at the start of the dive.
2015-10-29 09:50:37 +01:00
Jef Driesen
ae70d1efba Fix the dive mode for the Galileo Trimix.
Parsing the gas mixes has been implemented a while ago, so this check is
no longer neccessary.
2015-10-29 09:28:56 +01:00
Jef Driesen
8ac9778c9e Merge branch 'atom2' 2015-10-28 08:56:23 +01:00
Jef Driesen
aa2499ef0f Implement gas switches for the Hollis TX1. 2015-10-28 08:27:24 +01:00
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
Dirk Hohndel
4f321aef40 Merge branch 'master' into Subsurface-branch v4.5.1 2015-10-27 19:52:32 +09:00
Robert C. Helling
92a1919cf5 Mention Shearwater Nerd alongside with Petrel 2
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22 20:33:50 +09:00
Dirk Hohndel
2106cb2dab Add tank size reporting for Suunto EON Steel
Sadly the data we get from the EON Steel is a bit of a mess.
It doesn't really tell us if the data is metric or imperial (it always sends
both wet volume and working pressure). And in imperial mode the Suunto
engineers seem a bit confused. The pressure given (entered on the dive computer
in psi) is sent to us not in bar, not in atm... it's "something". As far as I
can tell it's a constant factor of 1.00069182389937 different from bar.
And the wet sizes are a bit to small to get the cuft size the user entered.
But instead of trying to guess and fix the mess, we just pass it through...

So this is somewhat useful, but not really what most users will want.

Linus started this commit with a few lines that parsed the right values out of
the data stream from the Suunto EON Steel. I then added the implementation of
the infrastructure to convert the raw data and report it back to the caller.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22 20:29:43 +09:00
Anton Lundin
854f58fa32 Cleanup and correct CCR detection
== has precedence over & and would have needed some parenthesis.

Instead of that, this moves that code into the block below which
already contains a correct CCR check.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-18 16:43:15 -07:00
Dirk Hohndel
058538e628 Use hidapi for Suunto EON Steel on Mac
libusb on Mac doesn't support HID devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-18 10:39:55 -07: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
Anton Lundin
138fd856bd Add deco model info strings to shearwater parser
This adds two strings describing the deco model information of the dive.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
v4.5.0
2015-10-14 05:52:53 -07:00
Janice
0efa420b71 Convert ndl/deco time to seconds. 2015-10-14 09:11:47 +02:00
Dirk Hohndel
1ccf937aa3 Merge branch 'master' into Subsurface-branch 2015-10-13 19:23:32 -07:00
Giorgio Marzano
95bdea93cd Use the correct memory layout and packet size. 2015-10-05 15:11:34 +02:00
Dirk Hohndel
da0073c971 Merge branch 'master' into Subsurface-branch 2015-10-02 06:18:51 -04: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
Claudiu Olteanu
8932b2a936 Fix dc_serial_native_open return check for Shearwater family
The dc_serial_native_open method doesn't return -1 on failures.
The failure errors can be DC_STATUS_INVALIDARGS, DC_STATUS_NOMEMORY,
DC_STATUS_IO.

Therefore we should check if the returned value is equal to
DC_STATUS_SUCCESS and pass it further.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-07 07:33:51 -07:00
Dirk Hohndel
9c7d1102d4 Fix compile errors on Mac
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-04 10:43:37 -07: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
Claudiu Olteanu
ad4bcffa23 Use custom set_timeout callback for Shearwater family
Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
sync-point sync-point-clean
2015-08-26 10:48:47 -07:00
Claudiu Olteanu
f103553df1 Use the custom set_timeout callback for HW_OSTC 3 family
Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:38 -07:00
Claudiu Olteanu
a6274a3a55 Add set_timeout callback for serial custom implementation
The new callback will be usefull when we will implement the support
for Windows. The implementation of native serial set_timeout method
uses a HANDLER on Windows and we will use the WinSock2 API which has
a socket descriptor.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:32 -07:00
Gaetan Bisson
adfff2d4a7 Add new functions to list of exported symbols
This is required in order to build those new public functions into the
shared library.

Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:25 -07:00
Linus Torvalds
f0e695b089 EON Steel: expose the gas switch cylinder in the "flags" field
This seems to be the simplest extension to the SAMPLE_EVENT_GASCHANGE2
format: the "value" remains the oddly encoded gas mix, but the "flags"
value (if non-zero) now contains the actual cylinder number we switch
to.

This will need a trivial patch to subsurface to take advantage of the
new data too.  But then we can actually distinguish between cylinders
that have the same gas mix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:09 -07:00
Linus Torvalds
fe2448e34f Add EON Steel personal adjustment parsing
Suunto calls it "Conservatism" in the dump, but "Personal adjustment" in
at least some of the documentation. That's what we expose it as.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:00 -07:00
Linus Torvalds
7fd201a400 Add EON Steel dive mode and transmitter ID information
This adds the divemode name (Nitrox, Trimix, Gauge, or whatever custon
name) and the transmitter ID as extra string information when
downloading from the EON Steel.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:54 -07:00
Linus Torvalds
c39dda89bc Suunto EON Steel: populate various string data
The EON Steel saves the dive computer firmware versions etc per dive,
which is really nice for upgrades: old dives done with older firmware
still show the firmware at the time of the dive.  That, in turn, is nice
because we can use it for a reliable dive ID - dive time with serial
number etc.

This uses the new DC_FIELD_STRING model to feed the hw/sw information to
the application, since we need the parser to access it.  It also returns
battery state and deco model information.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:48 -07:00
Claudiu Olteanu
0c8886ce70 Implement custom open device method for SHEARWATER family
Create a custom open method for SHEARWATER family.
This method can be used to pass a reference to a dc_serial_t
structure. In this way the applications can implement their
own implementation for a serial communication and set their
callbacks for the basic serial functions.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
53ccc4f43b Use the dc_serial_t structure in SHEARWATER family
Use the new structure in the SHEARWATER family implementation.
This patch opens a native serial device and use it
for the serial communication.

Also the patch uses the set of callback functions saved in the
dc_serial_t structure.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
8c3e44aa0c Implement custom device open method
This method can be used by external applications to open a
device and to pass their custom implementation for the
serial communication.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
5dbaa7a053 Implement custom open method for HW OSTC 3 family
Create a custom open method for HW OSTC3 family.
This method can be used to pass a reference to a dc_serial_t
structure. In this way the applications can implement their
own implementation for a serial communication and set their
callbacks for the basic serial functions.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
69bd993233 Use the dc_serial_t structure in HW OSTC family 3
Open a native serial device and use it in the HW OSTC3
implementation.

This patch replaces the old serial structure with the
new one, which can be used for custom serial implementations.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
a50a1e0688 Create a generic way to represent any type of serial communication
Add a structure which holds references to basic operations
on a serial communication. This can be used to pass a set
of function pointer callbacks in order to create a custom
implementation for serial communication.

Add a generic structure to represent the needed information
for a serial communication.

Implement the initialization method where the user can
pass a set of function pointer callbacks and set some
custom data for the serial device.

Create open method for the native serial implementation.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
b9e3f40d59 Extend the transport enum descriptor for serial communication
Add a new transport type which can be used to identify
Bluetooth serial communication.

Signed-off-by Claudiu Oleanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Anton Lundin
f184b45e09 Correct firmware version string from OSTC's
The format string was incorrect, producing firmware numbers as 3.2
instead of 3.02 as is the current OSTC firmware version.

This was reported via hw's forum:
http://forum.heinrichsweikamp.com/read.php?2,14550,14552

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Dirk Hohndel
0ff1dd15f5 Predator: don't report PPO2 unless in CC mode
Sending this in OC mode is redundant and might confuse applications that
assume they only get PPO2 data in CC mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00