summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
AgeCommit message (Collapse)Author
2015-09-13Store the number of detected o2 sensorsGravatar Anton Lundin
To make our logic to handle o2 sensors do usefull things we need to inform it of the amout of o2 sensors we got. This saves the max number of PPO2 samples we got from libdivecomputer as our number of o2 sensors. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-13Remove leftover bits between sensors and setpointGravatar Anton Lundin
Previously subsurface treated DC_SAMPLE_SETPOINT and DC_SAMPLE_PPO2 the same way. Back in "Store DC_SAMPLE_PPO2 as a o2 sensor", and "Support multiple o2 sensor values from libdc", i changed that and started to treat DC_SAMPLE_PPO2 as the o2 sensor values they are. The po2 variable there was a leftover from when ppo2 and setpoints where treated the same way, and should be removed. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09Exit with failure if the first dc_open method failsGravatar Claudiu Olteanu
If the dc_serial_*_open method fails then we should exit with an error and don't try to open the device using the native implementation. Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31Support multiple o2 sensor values from libdcGravatar Anton Lundin
libdivecomputer might call us with DC_SAMPLE_PPO2 multiple times, which means multiple sensors. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31Store DC_SAMPLE_PPO2 as a o2 sensorGravatar Anton Lundin
DC_SAMPLE_PPO2 represents a known ppO2, and not a setpoint. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-20Connect up serial_ftdi custom serialGravatar Anton Lundin
This connects the serial_ftdi implementation to subsurface, and builds libftdi1 for the android builds. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-30Add support for RBT reported sample valueGravatar Salvador Cuñat
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-07Allow to compile Subsurface with upstream libdivecomputerGravatar Dirk Hohndel
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-06Implement the custom Bluetooth serial communication and use itGravatar Claudiu Olteanu
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-02Use tank pressure data from libdivecomputer's DC_FIELD_TANKGravatar Dirk Hohndel
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-06-21Fix a number of resource leaksGravatar Dirk Hohndel
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-05-28Add explicit casts to silence compiler warningsGravatar Robert C. Helling
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-27Enable diagnostic logs from dc configurationGravatar Anton Lundin
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-04-29Add a default case for switch over dc_family_tGravatar Anton Lundin
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-04libdivecomputer.c: Remove unused parameter in parse_gasmixesGravatar Salvador Cuñat
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-04libdivecomputer.c: Add support for raw data buffer parse using libdcGravatar Salvador Cuñat
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-04libdivecomputer.c: Split dive_cb() callback in twoGravatar Salvador Cuñat
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-04Add errmsg() function for libdivecomputer.cGravatar Salvador Cuñat
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-03-19Fix a couple of typosGravatar Torstein Husebø
Signed-off-by: Torstein Husebø <torstein@huseboe.net> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-09Prevent a tank from looking undefined by mistakeGravatar Dirk Hohndel
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-01-22Set divemode to FREEDIVE now when we support thatGravatar Anton Lundin
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-19Remove the two annoying debug statementsGravatar Dirk Hohndel
These should have been removed ages ago... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-01-10Refactor dctype -> divemodeGravatar Robert C. Helling
... 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-09Now use our table when downloading from the dive computerGravatar Dirk Hohndel
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-09Don't use the result of unsupported libdivecomputer callsGravatar Dirk Hohndel
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>
2014-12-29Remove unused variableGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-12-29Clear stale pointers after freeGravatar Anton Lundin
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-27Keep undecoded firmware / serial info from libdivecomputerGravatar Dirk Hohndel
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-01libdivecomputer.c: reduce the scope of 'i' in sample_cb()Gravatar Lubomir I. Ivanov
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-11-25Consistent representation of O₂Gravatar Tim Wootton
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-24Let's not store more or less random dataGravatar Dirk Hohndel
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-21Add serial and firmware to the extra dataGravatar Dirk Hohndel
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-20Remember serial and firmware for divecomputersGravatar Dirk Hohndel
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-20Stop cluttering stout with DC_VENDOR dataGravatar Dirk Hohndel
This was intended for debugging and somehow stayed enabled. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-13Add subsurface_access()Gravatar Lubomir I. Ivanov
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-12Shows an error about wrong permissionsGravatar Salvo 'LtWorf' Tomaselli
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-11Remove leftover code for directly parsing Cobalt tank sizesGravatar Dirk Hohndel
This should have been ripped out as part of commit 4be760463422 ("Use libdivecomputer tank size when available"). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-11Fix getting tank information from libdivecomputerGravatar Dirk Hohndel
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-08Fix previous commit to compile with older versions of libdivecomputerGravatar Dirk Hohndel
That was silly :-( Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-11-08Use libdivecomputer tank size when availableGravatar Dirk Hohndel
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-08Add support for libdivecomputer DC_FIELD_DIVEMODEGravatar Anton Lundin
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-08Move calculate_string_hash into DC_FIELD_STRINGGravatar Anton Lundin
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-07Add support for libdivecomputer's new TEMPERATURE fieldsGravatar Dirk Hohndel
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-07Use the new DC_FIELD_STRING callback if it existsGravatar Linus Torvalds
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-10-20Make it possible to have samples without depth from libdivecomputerGravatar Linus Torvalds
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-19Make planner work again for CCR divesGravatar Robert C. Helling
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-08-14Add "download into private trip" dialog checkmarkGravatar Linus Torvalds
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-06Only show libdivecomputer "unlikely gas" warning onceGravatar Dirk Hohndel
Fixes #696 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-03Use Qt date localization instead of translated stringsGravatar Dirk Hohndel
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-06-11Don't silently ignore suspcious data from libdivecomputerGravatar Dirk Hohndel
Otherwise possible bugs in libdivecomputer won't get reported and fixed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>