2075 Commits

Author SHA1 Message Date
Linus Torvalds
3733b87ac9 Merge branches 'add_shearwater_teric_timesync' and 'add_ostc4_dump_error' of https://github.com/mikeller/libdc into Subsurface-DS9
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.
2023-07-08 16:50:45 -07:00
Michael Keller
b13ad617ac 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>
2023-06-14 12:37:11 +12:00
Michael Keller
838717dbae Add Time Synchronisation for the Shearwater Teric.
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>
2023-06-08 22:25:26 +12:00
Linus Torvalds
436063c74d Merge tag 'v0.8.0' into Subsurface-DS9
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
  ...
2023-05-27 16:18:41 -07:00
Michael Keller
763fc68741 Shearwater: Add time synchronisation.
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>
2023-05-20 19:25:20 +12:00
Jef Driesen
db9371cf9f Release version 0.8.0 2023-05-11 18:56:37 +02:00
Jef Driesen
49aa12b172 Fix the date of the v0.7.0 release 2023-05-11 16:27:55 +02:00
Jef Driesen
2f1b99f2f9 Add a missing filter for the Aqualung i750TC
Commit 58d410b1a217bbc1f03d5c7a5a203c139a92616c accidentally omitted the
descriptor filter function.
2023-05-11 16:26:40 +02:00
Jef Driesen
6c3bbb2cc7 Reduce the BLE output packet size to 20 bytes again
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.
2023-05-11 16:25:59 +02:00
Jef Driesen
1c8cd096b5 Integrate the new packet I/O in the backends
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.
2023-05-11 16:25:59 +02:00
Jef Driesen
40c95ca02a Add a generic packet I/O implementation
The new packet I/O provides a layered I/O for reading and writing a byte
stream from the underlying packet oriented transport.
2023-05-11 16:25:59 +02:00
Jef Driesen
72ddd6a439 Fix a typo in the documentation 2023-04-24 00:02:17 +02:00
Jef Driesen
d4472b758f Add support for the Divesoft Freedom and Liberty
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>
2023-04-24 00:02:17 +02:00
Jef Driesen
b0e77fd05f Integrate the HDLC stream in the eonsteel backend 2023-04-24 00:02:17 +02:00
Jef Driesen
cee9a2e926 Add a generic HDLC I/O implementation
The new HDLC I/O provides a generic I/O stream for reading and writing
HDLC encoded frames on top of another base I/O stream.
2023-04-24 00:02:17 +02:00
Jef Driesen
9c38ae3e01 Remove the local endianess functions
Replace the local functions for writing 16 and 32 bit little endian
values with the corresponding common functions.
2023-04-17 16:28:19 +02:00
Jef Driesen
629d567381 Use the correct function to free resources
Currently this doesn't make any difference because the
dc_device_allocate() function simply calls free(), but this may change
in the future.
2023-04-12 11:47:25 +02:00
Jef Driesen
bec4a747ff Add the udev rules to the distribution tarball 2023-04-07 20:37:19 +02:00
Jef Driesen
43f48af418 Add a README file to the contrib directory 2023-04-07 20:37:19 +02:00
Jef Driesen
e45c62b028 Include the revision in the Visual Studio and Android builds
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.
2023-04-07 20:37:17 +02:00
Jef Driesen
767a2fad91 Don't generate the Windows version resource
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.
2023-04-07 20:35:05 +02:00
Jef Driesen
083b1eb8de Move the Visual Studio project to the contrib directory
With this change all the alternative build systems are now located in
the contrib directory.
2023-04-07 20:35:05 +02:00
Jef Driesen
118f6d79ba Add a basic Android build system
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>
2023-04-07 20:35:02 +02:00
Jef Driesen
cf221de9b7 Disable the getopt argument permutation on Android
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.
2023-04-07 14:04:00 +02:00
Dirk Hohndel
3a2dc6cce4 Adapt dctool to recent API change
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2023-03-29 11:24:43 -07:00
Jef Driesen
86fd58c8c6 Move the sign extension function to a common place 2023-03-23 19:43:16 +01:00
Jef Driesen
1930b9eb59 Merge branch 'checksums' 2023-03-23 19:41:11 +01:00
Jef Driesen
554855cc7d Add the 16-bit CRC-ANSI functions
Yet another family of 16-bit CRC function. The only difference with the
already available CRC-CCITT algorithm is the choice of the polynomial.
2023-03-23 19:31:01 +01:00
Jef Driesen
27b471e76b Document the properties of the CRC functions 2023-03-23 19:30:23 +01:00
Jef Driesen
00033e4af0 Rename the 32-bit CRC functions
The new names make it easier to identify the normal and reflected
variant of the CRC function.
2023-03-23 19:30:23 +01:00
Jef Driesen
d327aea6ff Add a reflected variant of the 16-bit CRC-CCITT
The reflected variant of a CRC does reverse the bits of each input byte
and requires a different lookup table for an efficient implementation.
2023-03-23 19:28:37 +01:00
Jef Driesen
12f44f3410 Add an extra parameter for the xorout value
This change allows to calculate some more variants of the CRC-CCITT
algorithm with a single function.
2023-03-23 19:28:24 +01:00
Michael Keller
46d4bee8ab Add option to force overwrite firmware for OSTC4.
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>
2023-03-17 19:41:05 +13:00
Michael Keller
c288effa01 HW: Add gas type reporting through tank information.
Use tank information to report the type of gas used (open circuit /
diluent) for different gas mixes.

Signed-off-by: Michael Keller <github@ike.ch>
2023-03-17 10:23:48 +13:00
Michael Keller
d9dd30f327 HW: Add bailout events.
Add explicit events for OC bailout / switch back to closed
circuit on Heinrichs Weikamp dive computers.

Signed-off-by: Michael Keller <github@ike.ch>
2023-03-17 10:23:29 +13:00
Michael Keller
8b5b86fb4e HW: Apply the OSTC4 gas index offset to all HW computers.
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>
2023-03-17 10:21:54 +13:00
Michael Keller
4ddef92b80 HW OSTC4: Fix and improve CCR gas handling.
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>
2023-03-17 10:21:47 +13:00
Linus Torvalds
543bd58ddd Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
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
2023-03-16 09:49:21 -07:00
Linus Torvalds
8d3271e586 Revert "Limit the index to the fixed gas mixes"
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>
2023-03-06 12:02:45 -08:00
Jef Driesen
2ba9904757 Fix the OSTC4 diluent changes
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>
2023-02-23 23:46:13 +01:00
Michael Keller
648651e2d7 Heinrichs Weikamp: Increase parameter value buffer size.
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>
2023-02-22 18:26:03 +13:00
Linus Torvalds
7efedfbb2b Merge branch 'master' of https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
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
  ...
2023-02-19 17:10:25 -08:00
Jef Driesen
255a2dbb9a Keep open-circuit and diluent gas mixes separately
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.
2023-02-17 15:00:49 +01:00
Jef Driesen
ee78d6f65b Parse some extra gas mix information
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.
2023-02-17 14:45:05 +01:00
Jef Driesen
328812e95b Limit the index to the fixed gas mixes
The index in the gas change event should refer to the one of the fixed
gas mixes. All gas mixes with a higher index are either manual or
bailout gas mixes, and are reported with different events containing an
O2 and He percentages instead.
2023-02-17 14:45:05 +01:00
Jef Driesen
98c7887e9c Handle dives without a valid gas mix more explicit
Dives without a valid gas mix in the sample data (e.g. both the O2 and
He set to zero) are currently ignored by accident. Because the
o2_previous and he_previous variables were initialized to zero, those
invalid gas mixes were not processed.

Add an explicit check for such gas mixes to make this more obvious.
2023-02-17 14:43:32 +01:00
Jef Driesen
5fd9317533 Ignore all gas mixes for freedives
For freedives it makes no sense to report any gas mixes. The freedives
also use a different sample format, which doesn't generate any gas
change events.
2023-02-17 14:41:01 +01:00
Jef Driesen
9787bb7ac9 Always include all gas mixes defined in the header
Especially among technical divers, it's not uncommon to carry spare
tanks that will only be used in emergency situations (for example a
rebreather with one or more bailout tanks). Since those gas mixes are
not used throughout the dive, they were also not reported to the
application.

Fixed by reporting all configured gas mixes. Applications can still
obtain the previous result after manually inspecting the gas switch
events in the samples and filtering out the unused gas mixes.

This partially reverts commit c8b166dadbf961e17a9bd1cc28db3d92832ddf72.
2023-02-16 14:05:53 +01:00
Linus Torvalds
1b9aea3213 garmin parser: avoid build warning about converting pointer types
DECLARE_FIELD() uses array_uint_endian() to turn an integer type into
the right endianness.  It's all conditional on being an integer type,
but the compiler still sees the assignment (with a cast) for other
types, and complains about casting the 'unsigned int' return value to a
pointer, even when that case is not actually dynamically ever taken.

Fix the compiler warning by just changing the return type of this
conversion function to 'unsigned long' instead, which will match the
size of pointers on all relevant architectures.

Don't look at that macro too closely, you'll go blind.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-02-09 11:23:03 -08:00
Michael Keller
9a3363dc7d Added detection for bailout to OC / switch back to CC for CCR dives.
As a CCR diver I would like to see the ability to properly track the 'on
loop' / 'bailed out to open circuit' status directly in Subsurface,
because this is an important (or even the most important) bit of status
information during a CCR dive.  This should extend to the use of the
correct ppO2 / gas mix in the deco ceiling / tissue model calculation.

My idea for how to do this would be to track the 'type' ('diluent' / 'OC
bailout') for every gasmix / tank that is reported by the dive computer.

Most CCR capable dive computers that I am familiar with require the user
to enter two different gas lists for diluent and bailout, so this should
work with the existing libdivecomputer API for these.  Unfortunately I
think making this change in Subsurface will require a bit of work, as
the libdivecomputer field capable of tracking the 'type' of a gas or
tank (`cache->tankinfo[]`) does not seem to be consumed at all in
Subsurface.

So this just provides a prerequisite for the change in Subsurface by
populating `tankinfo[]`.  In addition to this it also triggers a message
on every switch from CC to OC and back, at least giving a visual
indication of these diver triggered events.  The messages can probably
be removed from libdivecomputer again once 'loop status' tracking has
been added to Subsurface.

Also included is a fix of the tab expansion mess that I created in
commit 2129403 ("Added facility to detect and interpret manual setpoint
switches for Garmin Descent computers").  Apologies for this, I've
switched to using a custom `.vimrc` for this project now.

[ Edited up the commit message a bit further   - Linus ]

Signed-off-by: Michael Keller <github@ike.ch>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-02-09 11:20:34 -08:00