Commit graph

153 commits

Author SHA1 Message Date
Salvador Cuñat
cfac25626b Add support for RBT reported sample value
RBT (Remaining Bottom Time) is a value calculated on the fly by some air
integrated divecomputers, for example Uwatec devices. This value is an
estimation based in some heuristic around time function pressure
gradients. This way, RBT would be the time a diver can spend at actual
depth without running out of gas (taking account of ascent, deco, if
required, and rock bottom gas reserve, if set).
Older Uwatec devices just made the calculus and only stored alarm events
if this time value reached zero, but modern devices store the value each
sample, in minutes.
It seems that Suunto Eon Steel is storing RBT values too, in seconds.

Libdivecomputer has supported RBT for a while, but Subsurface just
printed it to stdout and dropped it.

This adds support for RBT value on subsurface sample structure and shows
it in the profile's info box, right under TTS(calc), if selected, where
these two values can be easily compared by humans.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30 07:43:16 -07:00
Dirk Hohndel
fa69a1b7d5 Allow to compile Subsurface with upstream libdivecomputer
This will create an inconsistent build that has some UI features implying
BT support but those will be non-functional. I don't think this is the
right thing to do - either fail to build with a decent message or really
remove the BT support.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-07 21:41:22 -07:00
Claudiu Olteanu
198cc41959 Implement the custom Bluetooth serial communication and use it
Create a custom Bluetooth serial communication using the QTBluetooth
API and use it when the Bluetooth download mode is enabled.
First try to connect on RFCOMM channel 1 because this is the default
RFCOMM channel of SPP service for most devices. If this doesn't work
try again on RFCOMM channel number 5 because it could be a Petrel2 device.

Add a fake open function for the custom implementation. This is
used when the selected device is HW OSTC 2N and the Bluetooth
mode is activated, then fake the open call of the serial device.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-06 08:37:42 -07:00
Dirk Hohndel
1d59b028c9 Use tank pressure data from libdivecomputer's DC_FIELD_TANK
When libdivecomputer switched to the DC_FIELD_TANK API it apparently
stopped creating fake pressure samples at the start and end of a dive for
dive computers that don't have continuous pressure reporting but that
instead only report those two values.

This updates our code to take those values into account.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 06:21:00 -07:00
Dirk Hohndel
f5726c3d18 Fix a number of resource leaks
Free memory returned from parse_mkvi_value()
Free memory returned from printGPSCoords()
Free memory allocated in added_list and removed_list
Free memory allocated when adding suffix to dive site name
Free memory allocated in cache_deco_state()
Free memory allocated in build_filename()
Free memory allocated in get_utf8()
Free memory allocated in alloc_dive()
Free memory allocated as cache but never used

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21 21:13:32 -07:00
Robert C. Helling
22bfc4936f Add explicit casts to silence compiler warnings
clang complais when converting (char *) to (unsigned char *), so tell
it it's fine.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-28 08:16:37 -07:00
Anton Lundin
4321ef1d88 Enable diagnostic logs from dc configuration
This implements support for writing debug/diagnostic logs when
configuring dive computers and upgrading the firmware.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-27 15:37:43 -07:00
Anton Lundin
c38b7d3922 Add a default case for switch over dc_family_t
This adds a default case which just errors out for the switch over
dc_family_t instead of checking a uninitialized variable if this was
ever called with something else than one of the expected dc-family
types.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-29 14:53:03 -07:00
Salvador Cuñat
13a0ad020a libdivecomputer.c: Remove unused parameter in parse_gasmixes
data pointer is not used, so it can be safely removed.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:35:03 -07:00
Salvador Cuñat
094d0d9699 libdivecomputer.c: Add support for raw data buffer parse using libdc
Add function libdc_buffer_parser() intended to parse raw data buffers
prepared for libdivecomputer. We have to commit elsewhere the necesary
assembly tasks to achieve consistent data.

Actually only OSTCTools import makes use of this feature. Uwatec families
have been included as I expect to make use of this function for sample
parsing in datatrak import (and, may be in a far future, smartrak).

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:31:43 -07:00
Salvador Cuñat
0fe21637ad libdivecomputer.c: Split dive_cb() callback in two
dive_cb() needs a defined device to work as it's built for DC download
tasks.
Move part of the functionality of dive_cb() to a new function
libdc_header_parser() which can be used to parse headers from raw data
buffers with no device set.
Obviously dive_cb() will call the new funtion for header parsing too.

Two changes in logic:

1- In parse_gasmixes() set data pointer to NULL. This pointer is passed to the
function, but it's not used. While this data pointer exists in DC import, via
dive_cb(), it doesn't in file import as data has previously been set in the
parser.

2- While parsing gas mixes do not return on rc = DC_STATUS_UNSUPORTED because
it would end our dive parsing just if the device doesn't support gases, which
seems undesirable in both, DC or file import.

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:30:16 -07:00
Salvador Cuñat
e276ec65ba Add errmsg() function for libdivecomputer.c
Taken as is from libdivecomputer exaples/common.c to improve verbosity
on libdc return codes.
Intended to be used on error messages shown to the user on main window
complementarily to those messages managed by dev_info().

Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-04 10:28:21 -07:00
Torstein Husebø
6a5279b952 Fix a couple of typos
Signed-off-by: Torstein Husebø <torstein@huseboe.net>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-19 11:17:39 -07:00
Dirk Hohndel
c2e2391493 Prevent a tank from looking undefined by mistake
If we have no default cylidner set and get no data about an air tank from
libdivecomputer, our cylinder will look completely empty by mistake.
Always setting some kind of description fixes that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-09 13:40:17 -08:00
Anton Lundin
e0c0ba4836 Set divemode to FREEDIVE now when we support that
Previous code mapped all our free dive inputs to OC, but now when we
actually have a FREEDIVE divemode, we can do better.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-22 06:02:34 +12:00
Dirk Hohndel
d6499cc32a Remove the two annoying debug statements
These should have been removed ages ago...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-19 21:13:03 +12:00
Robert C. Helling
e219bc70f8 Refactor dctype -> divemode
... and repair a failed rebase (sorry).

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10 17:27:25 -08:00
Dirk Hohndel
7357633905 Now use our table when downloading from the dive computer
We pass a different table to libdivecomputer (and the uemis code) and have
that table filled. And then we simply copy the dives from that table into
the real dive_table when the user accepts the download.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 15:06:25 -08:00
Dirk Hohndel
037d1ceefa Don't use the result of unsupported libdivecomputer calls
We report a bug if this is not unsupported and not successful. And then use
the result. Hello? So if this is not supported, we still use the result?

Oops. This has been around for a long time.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-09 11:01:06 -08:00
Anton Lundin
3da8797e71 Remove unused variable
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 16:27:44 -08:00
Anton Lundin
8455b4b35c Clear stale pointers after free
This is so that we can re-use the same device_data_t in other calls that
doesn't allocate a context for example.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29 16:27:44 -08:00
Dirk Hohndel
9f95f3ce18 Keep undecoded firmware / serial info from libdivecomputer
This needs to become a string in libdivecomputer - but for now let's just
keep the integers so we can parse it elsewhere when we know which model it
is - the generic parsing into a string is completely bogus and needs to go.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-27 08:31:04 -08:00
Lubomir I. Ivanov
21bfe88a30 libdivecomputer.c: reduce the scope of 'i' in sample_cb()
Silences a warning about an unused variable.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-01 14:31:05 -08:00
Tim Wootton
f72ec5e29b Consistent representation of O₂
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-25 07:57:28 -08:00
Dirk Hohndel
702c751ecf Let's not store more or less random data
The backend needs to convert the firmware and serial information into a
sane string - Subsurface shouldn't try to do this by itself.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-24 12:21:49 -08:00
Dirk Hohndel
acb8a0e118 Add serial and firmware to the extra data
And add the missing newline to the debug output to help us identify
encodings for serial and firmware.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-21 21:42:00 -08:00
Dirk Hohndel
19aa4245b4 Remember serial and firmware for divecomputers
This is not the right way to get serial numbers and firmware versions. The
libdivecomputer interface here is simply broken. Those ARE NOT numbers.

But until we have the capability in libdivecomputer to return reasonable
strings to us, this could be a stop gap measure to help us understand how
these are formatted.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 15:04:37 -08:00
Dirk Hohndel
7cedc4d48f Stop cluttering stout with DC_VENDOR data
This was intended for debugging and somehow stayed enabled.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-20 15:04:37 -08:00
Lubomir I. Ivanov
4096383fb5 Add subsurface_access()
For our usage the method will acept UTF-8 paths,
which are converted to UTF-16 on Win32.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-13 11:58:59 -08:00
Salvo 'LtWorf' Tomaselli
e024a5b207 Shows an error about wrong permissions
If an import fails, the permissions of the device are tested and an
error message that mentions permissions is shown to the user.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-12 14:41:27 -08:00
Dirk Hohndel
b51710c01e Remove leftover code for directly parsing Cobalt tank sizes
This should have been ripped out as part of commit 4be7604634 ("Use
libdivecomputer tank size when available").

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11 01:43:20 -08:00
Dirk Hohndel
5c69f94bca Fix getting tank information from libdivecomputer
Silly type made us always get tank 0. So tanks 1 through n where wrong
(and repeating tank 0 instead).

Reported-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11 01:41:08 -08:00
Dirk Hohndel
fd997c1b15 Fix previous commit to compile with older versions of libdivecomputer
That was silly :-(

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 23:03:10 -08:00
Dirk Hohndel
4be7604634 Use libdivecomputer tank size when available
If the gasmix of a tank is not the matching gasmix in the list of
gasmixes, issue a warning (as so far we assume those are always in sync).

This patch removes our own parsing of the sizes because Subsurface 4.3
will require libdivecomputer 0.5 so this should be enabled by the time the
next release comes out, so let's just drop the redundant code.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 22:26:18 -08:00
Anton Lundin
df42f78486 Add support for libdivecomputer DC_FIELD_DIVEMODE
libdivecomputer recently gained a api for telling us which mode the
divecomputer was running in, so this uses that to tell us if it was a OC
or CCR dive.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:20:38 -08:00
Anton Lundin
42d3ed0431 Move calculate_string_hash into DC_FIELD_STRING
The calculate_string_hash is only used if DC_FIELD_STRING is defined, so
this removes a warning for everybody who doesn't build against a
libdivecomputer with DC_FIELD_STRING support.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08 11:20:04 -08:00
Dirk Hohndel
082e59ea72 Add support for libdivecomputer's new TEMPERATURE fields
Parse air temperature and water temperature if available from the dive
computer. Subsurface happily tracks the temperatures in the dive samples,
but for water temperature in the header ("overall" water temperature) we
currently support only one field. So I ordered the code so that if it is
available, the minimum water temperature will be used, absent a minimum
water temperature we use the maximum water temperature.

Side note:
Since the libdivecomputer maintainer disagrees with the Subsurface
developers regarding a sane way to allow a consumer of his library to
detect if a feature is supported in a particular commit of the library,
the way we decide whether to build this code or not is decidedly hacky.
DC_GASMIX_UNKNOWN happens to be a #define we can check that was added
right around the time the temperature support was added. Sadly there is
no #define that we could check to see if temperature fields are supported.
How insane is that...

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 22:55:38 -08:00
Linus Torvalds
0a27978014 Use the new DC_FIELD_STRING callback if it exists
This recognizes recognize some strigns (serial number and firmware
version), and the ones that it doesn't recognize it adds as extra data
using Dirk's new interface.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-07 20:55:18 -08:00
Linus Torvalds
46809bac4f Make it possible to have samples without depth from libdivecomputer
Normally, all samples have depths associated with them, and most dive
computers likely don't even have the concept of a sample without a depth.

However, the new Suunto EON Steel definitely has samples with just time
updates (and perhaps other data, like events) and no depth at all.  We
get unhappy about that, and interpret it as having a zero depth.  Which
doesn't look very nice.

This just makes all samples default to the same depth as the previous
sample.  For normal samples with a depth value, that will just override
that default.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-20 18:10:23 -07:00
Robert C. Helling
5f44fdd9cf Make planner work again for CCR dives
The latest CCR patches had rendered the planner not usable for CCR dives.
This patch corrects this (and reenables the CCR set point column for
segments). The problem was that a new member setpoint of struct divepoint
had been introduced, but there was already po2 which had the same meaning.
This patch merges the two and renames them setpoint to prevent future
confusion.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-19 07:07:07 -07:00
Linus Torvalds
5b14ed16ac Add "download into private trip" dialog checkmark
This adds a checkbox for the divecomputer download dialog that allows you
to tell the download to put the newly downloaded dives into a trip of
their own. That in turn will disable the dive merging with any existing
dives, which means that you will not mix up your newly downloaded dives
with any old dives.

That, in turn, is very convenient of you know that some of the dives were
done by other divers (or from testing that happened during servicing etc),
or the dive dates etc were wrong because the dive computer date had reset
due to battery changes etc.

Once you have all the dives in a private trip of their own, you can then
fix them up (delete dives you don't want to merge etc), and then after all
the data is ok you might want to merge the cleaned-up results with
previous trips etc, and then manually ask subsurface to merge the dives or
whatever.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-14 22:40:14 -06:00
Dirk Hohndel
9d801c663f Only show libdivecomputer "unlikely gas" warning once
Fixes #696

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-06 06:19:31 -07:00
Dirk Hohndel
2ad433671f Use Qt date localization instead of translated strings
This gets us consistent date format everywhere. The reordering of month
name and day of the month didn't work correctly on Windows, anyway.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03 13:02:32 -07:00
Dirk Hohndel
6ab95af9ac Don't silently ignore suspcious data from libdivecomputer
Otherwise possible bugs in libdivecomputer won't get reported and fixed.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-11 07:15:40 -07:00
Anton Lundin
692ad31ad3 Don't ignore actual diveable mixes
Fist is really obvious. I quite regularly decompress using pure O2.
It's as good a last decompression gas as you get.

The second is a bit harder. There are very few that dive with 80%+ helium
in their mixes but they exist, and there are real weirdos that dive
heliox, so they are actual diveable gases too.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-10 14:55:21 -07:00
Willem Ferguson
eaf6d56487 CCR code: Change to sample structure
1) All the variables in the sample structures are strongly typed
2) Two additional types were declared in units.h:
     o2pressure_t
     bearing_t
3) The following variables were added:
     diluentpressure
     o2setpoint
     o2sensor[3]
4) Changes to a number of files were made to chanf
     sample->po2 to sample->po2.mbar
     bearing to bearring.degrees

Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 17:05:25 -07:00
Dirk Hohndel
4a1b9312f3 Don't check for tank size information only on first tank
commit d681bdcb63 ("Only use default cylinder for first one") has a
stupid bug in that it only calls get_tanksize for the first tank. That's
of course completely bogus.

Thanks to Linus for catching this.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 13:46:35 -07:00
Dirk Hohndel
d681bdcb63 Only use default cylinder for first one
When downloading from a divecomputer it makes little sense to assume that
all tanks are the default cylinder.

There's a good case to be made for having a default first cylinder (you
always dive with your own cylinder, or you are always on a dive boat with
AL80 tanks), but in multi-cylinder situations this is much more likely to
cause unintended harm; for example for those dive computers that always
report their maximum number of cylinders, even if some of them aren't
used.  Here setting a default cylinder turns those entries from obviously
empty into something that appears to have meaning (i.e., cylinder type is
filled in) even though this was just a default added by Subsurface.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-15 13:16:03 -07:00
Dirk Hohndel
b6bbfdcc5f Avoid calling free on uninitialized dive variable
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-08 17:27:33 -08:00
Dirk Hohndel
8ab1fa3983 Fix memory leak when parsing a dive fails
We had all these repetitive calls to dc_parser_destroy but didn't free the
already allocated dive.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06 15:36:46 -08:00