77 Commits

Author SHA1 Message Date
Michael Keller
bff6f7c140 Fix Setting of the Device Serial Number.
Fix setting of the serial number in `dc_parser_new()`.

Fixes https://github.com/subsurface/subsurface/issues/4155

Signed-off-by: Michael Keller <mikeller@042.ch>
2024-05-03 16:09:02 +12:00
Michael Keller
edfb1a9c67 Import: Update Garmin Descent Import for libdivecomputer Update.
Update the importer for Garmin Descent to work with the latest upstream
version of libdivecomputer.

Signed-off-by: Michael Keller <github@ike.ch>
2024-02-14 11:38:31 +13:00
Michael Keller
d37cb91734 Merge remote-tracking branch 'libdivecomputer/master' into update_libdivecomputer_202402 2024-02-02 17:40:41 +13: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
Jef Driesen
63f5a4d652 Remove the dc_parser_set_data function
The dc_parser_set_data() function allows to re-use a parser object for
multiple dives. The advantages of this feature are actually very limited
in practice. The reduction in memory consumption is almost negligible,
because the amount of internal state in the parser is typically very
small. But the implementation requires some additional complexity
because each backend needs code to reset its internal state. Therefore,
the function is removed and the data and size needs to be passed
directly to the dc_parser_new() and dc_parser_new2() functions instead.

Because keeping a reference to the data has also caused issues in the
past, especially for applications implemented in a garbage collected
language, the data will now also get copied internally.
2023-05-15 22:19:37 +02:00
Jef Driesen
679db0bae6 Remove the clock parameters from the constructor
Only a few dive computer backends (reefnet, aladin and memomouse)
require the clock parameters for parsing the date/time. Therefore,
those parameters are removed from the constructor function and
applications should set the clock parameters with the
dc_parser_set_clock() function instead.
2023-05-15 22:19:36 +02:00
Jef Driesen
4e24b3a277 Pass the sample struct by reference
Because the sample struct is passed by value, the size of the structure
can't be changed without also changing the function signature and
breaking backwards compatibility. This prevents adding new fields in the
future, to support some new features.

When passing the sample struct by reference using a pointer, the size of
the pointer does always remains the same.
2023-05-15 22:19:36 +02:00
Jef Driesen
a34e909a84 Change the units for the sample time to milliseconds
Some dive computers, especially freediving computers, supports multiple
samples per second. Since our smallest unit of time is one second, we
can't represent this, and the extra samples are dropped. Therefore, the
units are changed to milliseconds to prepare supporting this extra
resolution.
2023-05-15 22:19:34 +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
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
9eef8c50c0 Add support for the Oceans S1
The Oceans S1 uses a plaintext and line based communication protocol
over BLE. The larger payloads, which also contain plaintext data, are
transferred using the XMODEM-CRC protocol.

Based-on-code-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-01-25 14:17:29 +01:00
Jef Driesen
86e9cc3443 Add support for the Deepblu Cosmiq+
The Deepblu Cosmiq+ uses a plaintext and line based communication
protocol over BLE, where the binary payload data is encoded as
hexadecimal characters.

Based-on-code-by: Linus Torvalds <torvalds@linux-foundation.org>
2023-01-25 13:32:14 +01:00
Jef Driesen
45b9ee8376 Remove a duplicated include statement 2023-01-23 21:10:10 +01:00
Jef Driesen
12c77a228e Add a public api to configure the clock synchronization
For dive computers where the reference time (epoch) of the device is
unknown, libdivecomputer uses the current time of the device (devtime)
and the host system (systime) to synchronize both clocks.

Currently, both timestamps are passed directly to the constructor of the
parser. With the new public function, the application can adjust the
timestamps afterwards.
2022-08-11 17:36:26 +02:00
Jef Driesen
6ab140461a Add a public api to configure the depth calibration
Some dive computers store the depth as an absolute pressure value (in
bar). To convert to a depth value (in meters), the atmospheric pressure
and water density are required. For dive computers that do not have
those values available, libdivecomputer uses a default value. With the
new public api functions, applications can adjust those default values.

Some dive computers already provided a backend specific calibration
function. Those functions are now deprecated. They are kept around to
maintain backwards compatibility for now, but they will be removed in
the next version.
2022-08-11 17:36:15 +02:00
Linus Torvalds
107f5b14e3 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream changes from Jef Driesen:

 - New dive computer support:
    - Ratio iX3M 2
    - Sherwood Amphos Air 2.0

 - Cleanups and fixes

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Ratio iX3M 2 models
  Add support for the Sherwood Amphos Air 2.0
  Replace switch statements with an array lookup
  Add Shearwater Perdix 2 and Petrel 3
  Update the Shearwater hardware IDs
  Fix the clock synchronization
  Remove unused time parameters
  Add support for a new Aqualung i200C variant
2022-07-30 17:18:51 -07:00
Jef Driesen
e6f091909b Remove unused time parameters
Since the clock synchronization has been removed (see commit
a1962558412b8c89a79656992c8e7f4d001065c2 for the details), those
parameters serve no purpose anymore.
2022-06-23 15:56:10 +02:00
Linus Torvalds
aff0c28d08 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge Jef's upstream updates:

 - Add support for Seac Screen and Action

 - Add support for Cressi Michelangelo

 - misc small fixes

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Seac Screen and Action
  Add an address parameter to the memory dump helper function
  Ignore invalid gas mixes
  Add support for the Cressi Michelangelo
  Move the C_ARRAY_SIZE macro to a common place
  Fix the timezone offset in the xml output
  Emit a devinfo event when downloading a memory dump
  Read the info and more info data during startup
  Use helper functions to decode multibyte values
  Fix changing the OSTC settings
2022-06-05 09:02:06 -07:00
Jef Driesen
4b4efb2c07 Add support for the Seac Screen and Action 2022-06-02 11:29:32 +02:00
Linus Torvalds
39dbb275cc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge Jef's upstream into the Subsurface branch:

 - support for new dive computers: Mares Pick Pro+, Deep Six Excursion,
   Crest CR-4, Genesis Centauri and Tusa TC1.

 - support freedive mode on Mares Smart Air

 - work with Oceanic dive computers regardless of whether they need the
   BLE handshake or not

 - OSTC updates: support bigger BLE packets in newer versions, fix
   setpoint in SCR mode

 - Shearwater updates: full dive mode parsing, correct timezone handling
   on Teric, support up to four transmitters on newer log versions.

* git://github.com/libdivecomputer/libdivecomputer: (26 commits)
  Read the extra tank information
  Add support for transmitter T3 and T4
  Limit the number of records for the Predator
  Report the timezone offset for the Teric
  Use the correct model number from the final block
  Use the dive mode stored in the header
  Report the correct dive mode for SCR dives
  Increase the size of the BLE packet cache
  Add support for the Genesis Centauri and Tusa TC1
  Read the hardware and software version
  Report the initial setpoint in SCR mode
  Add the divemode to the layout descriptor
  Re-order the fields in the layout descriptor
  Show the correct help message for the scan command
  Add support for the Crest CR-4
  Add udev rule for the Suunto EON Steel Black
  Ignore unsupported BLE handshake
  Detect NAK response packets
  Remove the initial gas switch
  Restore the original standard gravity factor
  ...
2022-02-27 12:20:09 -08:00
Dirk Hohndel
3057ac79c2 Mares Icon HD protocol: add serial as string
I verified that the unsigned integer in the devinfo header actually matches the
serial number shown in the "About" dialog on the device - so let's add this as
extra data string and make it user visible (and also allow Mares Icon HD style
devices to be reliably distinguished in Subsurface).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-08-20 11:03:12 -07:00
Dirk Hohndel
f2cc4ab7ef Suunto Vyper protocol: add serial as string
I verified that the unsigned integer in the devinfo header actually matches the
serial number printed on the device - so let's add this as extra data string
and make it user visible (and also allow Suunto Vyper style devices to be
reliably distinguished in Subsurface).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2021-08-20 11:01:30 -07:00
Ryan Gardner
75f260a941 Add support for the Deep Six Excursion
Based on original work and code by Ryan Gardner, with some additional
improvements and integration into libdivecomputer by Jef Driesen.
2021-08-17 22:38:53 +02:00
Linus Torvalds
9ab0800c00 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream updates from Jef:

 - add suppoort for various new variants of existing dive computers:

    + Suunto Eon Steel Black, and new variant of Zoop Novo

    + Sherwood Beacon

    + new Shearwater Perdix AI model number

 - add new Sporasub SP2 support

 - various minor fixes and updates

* 'master' of git://github.com/libdivecomputer/libdivecomputer: (22 commits)
  Add support for a new Suunto Zoop Novo variant
  Add support for the EON Steel Black
  Add support for the Sporasub SP2
  Fix an overflow in the progress events
  Use a common sleep implementation
  Fix the clang compiler flag detection
  Add Github Actions CI builds and releases
  Show a summary after configuration
  Extend the OS detection to non Windows platforms
  Implement the ndl/deco sample
  Fix the maximum depth
  Mark the McLean Extreme as supporting BLE
  Fix -Wcast-qual compiler warning
  Mark the new iX3M 2021 models as supporting BLE
  Add support for the Sherwood Beacon
  Remove the infinite timeout
  Simplify the loop for reading the packet header
  Add a new Perdix AI hardware type
  Fix the McLean Extreme fingerprint feature
  Perform the check for the NULL key earlier
  ...
2021-04-22 08:40:35 -07:00
Jef Driesen
6ef72ab420 Add support for the Sporasub SP2
The Sporasub SP2 uses a very simple communication protocol and memory
layout, but with some unusual aspects:

Dives are artifically limited to a maximum of 6000 samples.

Unlike all other dive computers, the dives are not stored in some kind
of ringbuffer structure. Once the memory is full, no new dives can be
recorded. The existing dives need to be erased first, and the dive
computer will start recording again at te start of the memory area. The
Sporasub application has an "Auto-clear watch memory after data
transfer" feature for this purpose.

I didn't implement a more efficient download algorithm because
downloading a full memory dumps takes less than 10 seconds.
2021-04-15 16:47:59 +02:00
Linus Torvalds
3c1e763a47 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream changes by Jef Driesen:

 - add support for Liquivision dive computers

 - add support for the Aqualung i470TC

 - extract out Atomic Aquatics Cobalt USB support as a iostream

 - misc fixes

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the OSTC4 firmware upgrade
  Handle a negative number of bytes as an error
  Update the example application
  Use the new USB transport for the Atomic Aquatics Cobalt
  Add an I/O implementation for USB communication
  Add support for filter parameters
  Disable direct access to the filter function
  Increase the receive timeout to 5 seconds
  Fix the McLean Extreme bluetooth name
  Add support for Liquivision dive computers
  Add support for the Aqualung i470TC
2020-08-20 12:36:38 -07:00
Jef Driesen
71a149d776 Add support for Liquivision dive computers 2020-07-09 17:02:32 +02:00
Linus Torvalds
6935fe717a Merge branch 'Oceans-S1' into Subsurface-DS9
Add initial support for the Oceans S1.

This expands a bit on the generic functions for the field-cache code,
and uses that to then add a fairly minimal Oceans S1 downloader.

And while it's minimal, it downloads about everything the S1 offers,
which is mainly just depth and temperature.

There are a few fields that it currently doesn't use, notably the
events and NDL information that the dive computer presumably reports in
the auxiliary data that comes in the sample, but without documentation
and more testing I'm not comfortable parsing that.

There's also some "current dive computer state" that isn't imported,
like the battery status.  I know how to read it, but it's not per-dive
data that could be added as extra fields: it's literally just the
current dive computer battery state at the time of the download.

The Oceans team said they'll provide more information about the
download, so this might be expanded in the future, but it seems fairly
usable even in this form.

Thanks to Dhaval Giani for sending me his Oceans S1 as a loaner, and to
Seth Garrison for doing the initial BLE packet dumps that made me think
it was fairly easily doable.

* Oceans-S1:
  Oceans S1: polish up the downloading logic for usability
  Oceans S1: actually download all dives and parse them
  Oceans S1: fill out core download protocol details
  Oceans S1: start filling in protocol details
  Oceans S1: start documenting the download format and first packets
  Add skeleton for Oceans S1 downloader
  Add generic dc_field_get() helper
2020-06-25 11:33:12 -07:00
Linus Torvalds
6b22340ddc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9
Merge upstream libdivecomputer updates from Jef Driesen:

 - Jef merged the EON Steel dive sorting fix we had in our branch: one
   less difference to upstream

 - Jef merged the McLean Extreme support with some updates and cleanups,
   this just takes all his changes.

 - manual pages for iostream

 - various minor fixes and updates from Jef

* git://github.com/libdivecomputer/libdivecomputer:
  Update the gitignore file
  Update the man pages for the new iostream functions
  Purge the serial port buffer during initialization
  Add support for the McLean Extreme
  Suunto Eon Steel: sort the dive list properly
  Remove the salinity compensation
  Fix the hwOS ppO2 bug for firmware v3.08
2020-06-25 11:24:00 -07:00
Linus Torvalds
d58b8f6928 Add skeleton for Oceans S1 downloader
This does nothing, but fills in all the basic boiler plate code and data
structures.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-23 13:28:10 -07:00
David Carron
8d35ee6978 Add support for the McLean Extreme 2020-06-08 13:45:43 +02:00
David Carron
ee84202b2b Add support for the McLean Extreme dive computer
Initial support for McLean Extreme

Signed-off by: David McLean Carron <david_de_carron@hotmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-18 09:52:17 -07:00
Linus Torvalds
025fb5ed1a Add serial number to parser creation for ostc, atom2, shearwater and suunto d9
These backends want the serial number for reporting, and can't get it
any other way.

We really should re-organize this.  It's a nasty source of pointless
changes wrt upstream libdivecomputer, and I'm not convinced it's worth
the pain.

We also don't even have a consistent ordering for the arguments. Oh well.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00
Linus Torvalds
8594445088 Add support for the Deepblu Cosmiq+ dive computer
Somewhat basic support, but the data the Deepblu Cosmiq+ reports is
pretty basic.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00
Linus Torvalds
4e9e94d9f8 Add backend for Garmin Descent Mk1
This uses pretty much all of our new infrastructure: the USB storage
iostream for the actual IO, the field-cache for the divecomputer fields,
and the string interface for the events.

It's also a very fast downloader.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:05:37 -07:00
Jef Driesen
b92cf6de69 Remove the obsolete hwos parameter
In commit 2829f7ebf9902170bf653d67dbe412a0a4f140cf, the hwos parameter
of the hw_ostc_parser_create() function was kept to preserve backwards
compatibility. Since the function has been removed from the public api,
the parameter can be removed now.
2019-11-21 11:07:07 +01:00
Jef Driesen
e363e5b1fd Add support for the Cressi Goa and Cartesio 2019-01-14 21:14:30 +01:00
Jef Driesen
472e9e984c Add support for the Tecdiving DiveComputer.eu 2018-06-22 23:24:30 +02:00
Jef Driesen
8aef4a49a0 Unify the Uwatec Smart, Meridian and G2 backends
The Uwatec Smart, Meridian and G2 backends are almost identical, except
for the low-level packet sending and receiving code. With the new I/O
layer, those three backends can easily be unified in a single backend.

The Meridian and G2 are completely removed, only the family types are
kept for backwards compatibility.
2018-06-22 23:13:44 +02:00
Jef Driesen
0a5623a949 Use the correct model number
The model number reported by the Scubapro G2 is 0x32.
2017-06-28 15:32:39 +02:00
Linus Torvalds
f107d7c0d8 Add initial Scubapro G2 frontend
The back-end parser seems to be the same as for the Uwatec Smart (aka
Galileo Sol).  At least that's the assumption right now.

The downloader just uses USB HID (very similar to EON Steel) rather than
the horrible IrDA thing.

There's also eventually a BLE thing, but that's for the future.

This is an unholy mixture of the Uwatec Smart downloader logic and the
EON Steel usbhid transfer code.  The back-end is pure Uwatec Smart
(model 0x11, same as Galileo Sol).

I'm not at all sure this gets everything right, but it downloads
*something*.

[Jef Driesen: Renamed the backend to uwatec, and made some smaller
              cosmetic changes to match the existing coding style.]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 15:32:39 +02:00
Jef Driesen
fe2d128b44 Apply the calibration correction only for the Predator
The calibration values for the Petrel are typically in the range 1600 to
2400, while for Predator they are much smaller, with values in the range
800 to 1400. The consequence is that the calculated ppO2 values are too
low for the Predator. Adding a constant offset of about 1000 changes the
calibration value to be in approximately the same range as the Petrel,
and hence more reasonable ppO2 values. But this correction should only
be applied for the Predator, and not the Petrel.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-05-11 16:18:23 +02:00
Jef Driesen
c5f089b4a6 Remove unnecessary helper functions
The second variant of the open or create functions were introduced to
maintain backwards compatibility. But after being removed from the
public api, these functions serve no purpose anymore, and can be removed
completely.
2017-04-19 11:33:17 +02:00
Jef Driesen
d1a06e784c Remove deprecated functions from the public api
The vendor_product_parser_create() and vendor_product_device_open()
functions should be called indirectly, through the generic
dc_device_open() and dc_parser_new() functions. And the
vendor_product_extract_dives() functions are internal functions that
should never have been part of the public api in the first place.
2017-04-18 08:41:10 +02:00
Jef Driesen
07dcc8998b Add support for the Cressi Drake
The Cressi Drake is a mainly a freedive computer. The data format is
almost identical to the Leonardo. The main difference is that a single
dive now contains an entire freedive session. Each freedive in the
session is delimited with a 4 byte header containing the surface
interval and a special marker.
2016-12-30 22:25:14 +01:00
Jef Driesen
2829f7ebf9 Add an ostc3 specific function with the model number.
To be able to pass the OSTC 3 model number to the parser, and preserve
backwards compatibility, we need a new function. The new function should
also be used for the Frog, by passing zero as the model number.

Using the hw_ostc_parser_create() function with the hwos parameter set
to one, is now deprecated but will remain supported for backwards
compatibility.
2016-07-23 23:14:13 +02:00
Jef Driesen
ad2257569c Add a new dc_parser_new2 convenience function.
For applications supporting offline parsing (like libdivecomputer's own
dctool application), some device specific knowledge is still required in
order to map a particular model to the corresponding backend. The new
convenience function will take care of that internally.

The already existing dc_parser_new() function does the same, but
requires an open device handle, which makes it unsuitable for offline
parsing.
2016-07-22 21:14:33 +02:00
Jef Driesen
b41ecd0c15 Add a parameter with the model number. 2016-07-11 21:47:29 +02:00
John Van Ostrand
9a4e2b75a5 Add support for the Cochran Commander and EMC. 2016-03-22 20:09:45 +01:00
Jef Driesen
ff29d218bb Use helper functions to allocate and free objects.
Both the allocation and initialization of the object data structure is
now moved to a single function. The corresponding deallocation function
is intended to free objects that have been allocated, but are not fully
initialized yet. The public cleanup function shouldn't be used in such
case, because it may try to release resources that haven't been
initialized yet.
2016-01-05 20:40:21 +01:00