aboutsummaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
AgeCommit message (Collapse)Author
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>
2014-06-10Don't ignore actual diveable mixesGravatar Anton Lundin
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-03CCR code: Change to sample structureGravatar Willem Ferguson
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-03-15Don't check for tank size information only on first tankGravatar Dirk Hohndel
commit d681bdcb6308 ("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-15Only use default cylinder for first oneGravatar Dirk Hohndel
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-08Avoid calling free on uninitialized dive variableGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-06Fix memory leak when parsing a dive failsGravatar Dirk Hohndel
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-05Another small tweak to whitespace toolGravatar Dirk Hohndel
clang-format doesn't appear to reindent multi line #define statements correctly - so this hopefully will clean those up. The included whitespace corrections to the code should stay in place when using the updated tool. This includes cleaning up some multi-line comments that were messed up the last time around as well as a few other minor changes. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-03Remove pointless assignmentsGravatar Dirk Hohndel
tissue_tolerance wasn't used after it was assigned. type was overwritten after it was assigned. serial was overwritten after the last /= 100. event is assigned in the for loop. clear isn't used after the assignment Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-27Massive automated whitespace cleanupGravatar Dirk Hohndel
I know everyone will hate it. Go ahead. Complain. Call me names. At least now things are consistent and reproducible. If you want changes, have your complaint come with a patch to scripts/whitespace.pl so that we can automate it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-26set the download progress bar to zero after a downloadGravatar Danilo Cesar Lemes de Paula
Before that, the behaviour was that in case of an error or a re-download, the progress bar would appear for a few milliseconds with the old value. Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Use "rint()" instead of rounding manually with "+ 0.5"Gravatar Linus Torvalds
rint() is "round to nearest integer", and does a better job than +0.5 (followed by the implicit truncation inherent in integer casting). We already used 'rint()' for values that could be negative (where +0.5 is actively wrong), let's just make it consistent. Of course, as is usual for the messy C math functions, it depends on the current rounding mode. But the default round-to-nearest is what we want and use, and the functions that explicitly always round to nearest aren't standard enough to worry about. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-12Fix default value for missing surface pressure from divecomputerGravatar Linus Torvalds
We should *not* default to the incorrect "1 bar". Instead, we should leave the resuling pressure at 0 mbar, which leaves visual entries empty and uses the default surface pressure for calculations. Reported-by: Pedro Neves <nevesdiver@gmail.com> Cc: Patrick Valsecchi <patrick@thus.ch> Cc: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-02-10Add support for heartrate and bearing information in samplesGravatar Linus Torvalds
libdivecomputer already supports this, but we didn't save it. Tested-by: Oscar Isoz <jan.oscar.isoz@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-27Fix the semantics of the dive_cbGravatar Dirk Hohndel
Libdivecomputer wants us to return true if it should continue to loop over the dives and false if we want to stop. Don't pass errors back. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-16Convert the C code to using stdbool and true/falseGravatar Anton Lundin
Earlier we converted the C++ code to using true/false, and this converts the C code to using the same style. We already depended on stdbool.h in subsurfacestartup.[ch], and we build with -std=gnu99 so nobody could build subsurface without a c99 compiler. [Dirk Hohndel: small change suggested by Thiago Macieira: don't include stdbool.h for C++] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08Write the event data to the libdivecomputer log.Gravatar Jef Driesen
For some devices, the event data contains important data that is required for parsing the dives, but which is not present in the full memory dump. Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-01-08libdivecomputer.c: Try not to pass NULL to fopen()Gravatar Lubomir I. Ivanov
C99 7.1.4, says nothing about passing NULL to fopen(), which means that it isn't portable and there are no guaranties that the return will be a NULL pointer or that that a library implementation will not assert or SYSSEGV in the middle of the fopen() branch. libdivecomputer.c's 'dumpfile_name' and 'logfile_name' could cause problems in that regard. A possible fix for #411 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24Enable libdivecomputer log or dump from the UIGravatar Dirk Hohndel
Pick filenames for these functions as they are selected. Use the windows-safe fopen function. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24Support downloading memory dumps.Gravatar Jef Driesen
Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24Enable diagnostic logging from libdivecomputer.Gravatar Jef Driesen
Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-24Remove an unnecessary function call.Gravatar Jef Driesen
Signed-off-by: Jef Driesen <jefdriesen@telenet.be> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-12-11Add some sanity checksGravatar Anton Lundin
If first sample is not a DC_SAMPLE_TIME, we would have bin dereferencing a null pointer. This might actually never happen, unless we talk to a really weird dc, but this makes the static analyzer happier. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-29Add comment for "below floor" eventGravatar Dirk Hohndel
This one is a tough one for translators. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-27Remove some constants and use helpers insteadGravatar Anton Lundin
We have allot of helpers, use them instead of local variants. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-23Use a default tank when populating tank data after downloadGravatar Dirk Hohndel
This is super-simplistic and also is kinda wrong. It forces all tanks that haven't been specified by the DC (so far only Atomics Aquatics Cobalt and UEMIS Zurich (which doesn't even use libdivecomputer) to be AL80. Just as we used AL80 as default for manually adding tanks. Obviously this needs to become an option where the user can pick. See #145 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>