We end up using the FIT file name as the "fingerprint" for the dive, and
include it at the beginning of the dive data as such. And because of
how Garmin encoded the FIT files, we ended up having a fixed 24-byte
length for this, which is normally the date encoding:
YYYY-MM-DD-HH-MM-SS.FIT
with the terminating NUL character.
Of course, then Garmin started using a short-form encoding too
(presumably due to FAT filesystem limits), and we have magic code to
sort the dates properly, using the name format
YMDHMMSS.FIT
with the numbers encoded in a shorter format (eg "C4ND0302.fit" is
equivalent to "2022-04-23-13-03-02.fit"). See name_cmp() and
parse_short_name() for details.
Anyway, because we use the (zero-padded) 24 characters of the name as
the fingerprint, we used a fixed-size buffer for the filename that was
limited to that maximum size Garmin creates.
But then you download those things, and have multiple vendors, and
suddenly that 24-character limit on the filename is very annoying.
Instead of fixing this in some clean and generic way, let's just raise
the namelength limit to something bigger, and continue to use the first
24 characters of the name for the fingerprint.
Pretty it isn't, but it makes it slightly easier to import random FIT
files that don't conform exactly to the traditional Garmin format.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Since we can now parse FIT files from other vendors than Garmin (ie the
Suunto FIT file export), let's expose this as a generic "FIT file
import" in the dive computer list.
It's all still very much using the Garmin parser, but uses a model ID
that is zero. The only difference that makes is that it also tells the
parser to treat the result as a dive even if it cannot find the actual
dive markers that Garmin uses, since those won't exist in the limited
FIT file export.
This is still somewhat inconvenient, in that you cannot point to the
file itself, you can just point to the directory that contains FIT
files. And right now we have an artifical length limitation on the
filenames, but I'll fix that next.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This was the _actual_ reason why the Suunto FIT file import fell flat on
its face: it adds records with developer fields in them, and I just had
no idea how to parse them.
It turns out that they aren't all *that* horrible to parse: they are
kind of like a special case of the regular FIT event fields.
And no, this does not really parse them: it only parses the layout, and
using that it can then skip the developer fields without causing the
decoder to go all wonky and lose stream synchronization.
At least it works for the specific case of the Suunto FIT files, and the
code makes some amount of sense. The FIT format may be odd, but at the
same time it's most definitely designed for pretty simplistic devices,
so it's not some kind of crazy XML thing.
This gets us parsing those Suunto FIT files at least partially.
That said, it is all very rough indeed, since you have to lie and claim
you're downloading from a Garmin, and have to set up the whole magic
'Garmin/Activity/' directory structure and limit the file size to the 24
characters that Garmin uses.
So this is by no means the real solution.
Considering that Jef doesn't want the Garmin parser in libdivecomputer
anyway, the proper solution might be to move this all to subsurface, and
make it be a "FIT file import" thing instead. Annoying, but on the
other hand it has also been a bit awkward to have it in libdivecomputer.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This turns out to have been another false turn: mis-parsing the FIT file
caused us to think it had compressed records.
So I spent much too much time trying to figure out how those compressed
records actually work. This is the result.
It looks like the only difference between a compressed record and a
regular one is that the compressed record has a single-byte "this is the
record type and the time offset" field at the start. That basically
avoids the need of then having a full 4-byte absolute time for such a
record.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This is an empty stub for the HRM profile message, which isn't actually
used by anything I know of, but came up as a result of some mis-parsing
of odd FIT files generated by the Suunto mobile app.
Losing synchronization in the FIT file then caused the parser to think
it needed this message type, and not having it then caused an early
abort.
While it's not actually needed once parsing things correctly, since I
looked up the message number and name for this message type, let's just
keep it around. It won't hurt, and maybe it avoids me having to look it
up in the future.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Instead of returning an error on unrecognized input when parsing, just
skip to the end of the buffer. This makes at least partially parsed
data available, which can help figure out what ended up happening.
This was part of my "Suunto also does FIT files now, and does them very
differently from Garmin" series. I think I parse the Suunto files right
now, but next time this happens, I'd rather get partial data than no
data at all.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Pull libdivecomputer updates from Michael Keller:
- Add time synchronisation for the Shearwater Teric
- Fix two OSTC4 buglets
* 'add_shearwater_teric_timesync' of https://github.com/mikeller/libdc:
Add Time Synchronisation for the Shearwater Teric.
* 'add_ostc4_dump_error' of https://github.com/mikeller/libdc:
Fix bugs in OSTC4 support.
Fix two bugs in the support for OSTC4:
- change block size for writes back to 64 bytes to prevent buffer
overflow on the dive computer side;
- added 'unsupported' response for the dump command on OSTC4.
Signed-off-by: Michael Keller <github@ike.ch>
Add time synchronisation support for the Shearwater Teric. Unlike the
other Shearwater dive computers this model has basic support for time
zones, so we need to set the time in UTC and configure the time zone
offset.
Signed-off-by: Michael Keller <github@ike.ch>
Merge upstream version 0.8.0 into our libdc fork.
Since we tracked the development branch, we already had merged all the
main changes, but it's been a couple of months since the last upstream
merge, and there were a few new changes upstream:
- Divesoft Freedom and Liberty support
- A couple of iostream abstraction layers: a new 'packet layer' and a
HDLC layer, moving code from low-level dive computer downloaders to
generic iostream layers.
- misc minor updates
* tag 'v0.8.0': (25 commits)
Release version 0.8.0
Fix the date of the v0.7.0 release
Add a missing filter for the Aqualung i750TC
Reduce the BLE output packet size to 20 bytes again
Integrate the new packet I/O in the backends
Add a generic packet I/O implementation
Fix a typo in the documentation
Add support for the Divesoft Freedom and Liberty
Integrate the HDLC stream in the eonsteel backend
Add a generic HDLC I/O implementation
Remove the local endianess functions
Use the correct function to free resources
Add the udev rules to the distribution tarball
Add a README file to the contrib directory
Include the revision in the Visual Studio and Android builds
Don't generate the Windows version resource
Move the Visual Studio project to the contrib directory
Add a basic Android build system
Disable the getopt argument permutation on Android
Move the sign extension function to a common place
...
Add time synchronisation for Shearwater dive computers.
This synchronises the local time, which is all that is supported by all
Shearwater models except for the Teric.
Time synchronisation including the time zone for the Teric still has to
be added.
Signed-off-by: Michael Keller <github@ike.ch>
The newer u-Blox Nina B2 bluetooth module supports larger packets up to
244 bytes, but the older Telit/Stollman bluetooth module does not.
Trying to send a packet larger than 20 bytes fails. For maximum
compatibility, limit the output packet size to 20 bytes.
Replace the custom packet handling code in the iconhd and ostc3 backends
with the new layered packet I/O, and also integrate it into the idive
and extreme backends.
The latest versions of the Divesoft Freedom (HW 4.x) and Liberty (HW
2.x) dive computers support BLE communication. Previous generations did
support only a mass storage mode, where the dives are available as DLF
files. The BLE communication protocol uses HDLC framing for the data
packets. The dives downloaded over BLE have the same data format as the
DLF files.
Co-authored-by: Jan Matoušek <jan.matousek@rekomando.cz>
Tested-by: Jakub Hečko <jakub.hecko@divesoft.com>
During troubleshooting it's very convenient to know the exact version
used in a bug report. With the git commit SHA1 added to the version
string in all builds, that becomes very easy.
The Windows version resource is compiled and can include the (generated)
version.h header file for the definition of the version macros. There is
no need to have it generated by autotools. Less generated files makes it
easier to use other build systems, like Visual Studio.
Add a basic Android.mk for building with the Android NDK. This can serve
as a good starting point for developers integrating libdivecomputer into
an Android application.
Co-authored-by: Sven Knoch <info@divinglog.de>
On Android operating systems, the getopt() function is posix compliant
and thus the option processing stops when the first non-option is found.
But the getopt_long() function permutes the argument vector, just like
the GNU implementation.
Using a leading '+' character in the option string disables the
permutation again.
In order to support development of the open source firmware of the
OSTC4.
This is needed in order to be able to install firmware with the same
version number multiple times during development and testing.
Signed-off-by: Michael Keller <github@ike.ch>
Apply the gasmix index offset used by the OSTC4 on CCR dives to all
Heinrichs Weikamp computers and all dive types.
Signed-off-by: Michael Keller <github@ike.ch>
Fix a bug for the OSTC4 using the wrong gas after (diluent) gas
changes because the diluent gas index is offset by 5 when in CCR mode.
Also fix a bug adding manually entered gases on CCR dives as diluent
on OSTC4 - only OC gases can be manually entered on this dive computer.
Signed-off-by: Michael Keller <github@ike.ch>
Merge Jef's upstream fix for the OSTC4 CCR gas parsing issue reported by
Michael Keller.
This also effectively obviates (and undoes) the revert I did in commit
8d3271e586cd.
* https://github.com/libdivecomputer/libdivecomputer:
Fix the OSTC4 diluent changes
This reverts commit 328812e95bfe7c6c9d2a8d36c75144f05c7dc9dc.
This turns out to cause fatal parse failures for the cases where the gas
change refers to a manual or bailout gas.
As noted by Jef in that commit, we should likely report those
differently, but in the meantime, at least don't fail the download.
See the original report at [1], and a (at this point still contentious)
bigger change to gas switch reporting at [2]. This revert exists purely
as a "make it at least work for now".
Reported-by: Michael Keller <github@ike.ch>
Link: https://github.com/subsurface/libdc/pull/46#issuecomment-1438313959 [1]
Link: https://github.com/subsurface/libdc/pull/44 [2]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
The hwos devices support 5 gas mixes for open-circuit and 5 diluents for
CCR dives. Internally, both sets are stored separately, but depending on
the dive mode only one of both sets gets stored in the dive header. The
gas change event contains the index of the corresponding gas mix or
diluent, and should always be in the range 1 to 5.
The OSTC4 behaves a bit different from the other hwOS models and uses
index 6 to 10 for the diluents. That means the index needs to be
adjusted to refer to the correct mix in the dive header.
Reported-by: Michael Keller <github@ike.ch>
Get rid of truncation warnings and possible string truncation by
increasing the size of the buffer used for parameter values. There is
enough space to display up to 64 characters.
Signed-off-by: Michael Keller <github@ike.ch>
Merge upstream updates from Jef Driesen:
- Deepblu Cosmiq+ support has been merged upstream
- Oceans S1 support has been merged upstream
- Various new models supported: Cressi Donatello, Scubapro G2 TEK, new
Excursion v6+ firmware.
- misc core changes, most notably supporting a new annoying specialized
binary format for "decomode", because Jef still can't deal with
strings.
- lots of small details
* https://github.com/libdivecomputer/libdivecomputer: (58 commits)
Keep open-circuit and diluent gas mixes separately
Parse some extra gas mix information
Limit the index to the fixed gas mixes
Handle dives without a valid gas mix more explicit
Ignore all gas mixes for freedives
Always include all gas mixes defined in the header
Add support for the new Excursion v6+ firmware
Add support for the HP CCR tank pressure
Use the correct field for the setpoint sample
Add support for the Oceans S1
Add support for the Deepblu Cosmiq+
Add missing functions for accessing big/little endian values
Move the snprintf functions to the platform module
Repeat the handshake every few packets
Enable big page support
Remove the model number from the vtpro struct
Add the model number to the version table
Move all model numbers to the common header
Remove a duplicated include statement
Add support for the 300bar pressure sensor
...
The OSTC stores either the OC gas mixes or the CCR diluents depending on
the dive mode. For CCR dives, there is also bailout to an OC gas
possible, and those gas mixes are added dynamically to the manual gas
mixes.
The Shearwater dive computers store both the configured OC gas mixes and
CCR diluents in the header.
In both cases, the gas change events should reference the correct type
of gas mix. This patch takes care of that.
Keep track of the gas mix type, and whether the gas mix is enabled or
not. Right now this extra information isn't really used for anything
yet, but it's available for future use.