2045 Commits

Author SHA1 Message Date
Jef Driesen
2c5ebef594 Add udev rules for hidraw devices
The hidapi-hidraw variant of the hidapi library needs access to the
specific /dev/hidraw* device nodes. The existing udev rules for the USB
devices don't apply to the hidraw device nodes.
2022-11-25 13:25:23 +01:00
Jef Driesen
913a65fde6 Allow to specify the hidapi library variant
On Linux, the hidapi library is usually available in two variants:
hidapi-libusb and hidapi-hidraw. By default, the autotools build system
won't be able to detect those variants (due to the difference in the
name) and will automatically fallback to the libusb implementation
instead.

If for some reason the hidapi library should be used, the preferred
hidapi variant can now be specified during configuation with a
parameter:

  ./configure --with-hidapi=hidapi-libusb|hidapi-hidraw

The default value for the parameter remains 'hidapi'.
2022-11-25 13:25:23 +01:00
Jef Driesen
5218d3921a Read the software and hardware version 2022-11-23 08:37:25 +01:00
Jef Driesen
6874130743 Add the return type to the function definition
In commit 12c77a228e84f1ceed520b6afb53b4b64ea9def6, the return type of
the function was accidentally omitted.
2022-11-19 17:43:46 +01:00
Charlotte Koch
2f3a057969 Look for select(2) in a more reliable place 2022-11-14 13:29:28 +01:00
Greg McLaughlin
c2102f62d6 Add support for parsing bookmark events
The bookmark value is a bitfield indicating the type of bookmark:

  1 - Pressed the bookmark button during a dive
  2 - Reset the stopwatch
  4 - Unknown
  8 - Unknown
2022-11-10 14:09:05 +01:00
Jef Driesen
bf93040ab1 Receive only a single USB packet at a time
The hidapi based implementation returns as soon as the first packet is
received, while the libusb based implementation tries to read the
requested number of bytes. That fails with a timeout if the requested
number of bytes is larger than the size of a single packet and no
further packets are received.

Avoid this problem by limiting the size to the maximum packet size.
2022-11-10 14:03:46 +01:00
Jef Driesen
8a6abab1da Update the Github actions
The Github actions need an update due to upcoming deprecations:

 * The 'set-output' command is deprecated [1]. Update to write to the
   GITHUB_OUTPUT environment file instead.

 * All Github actions using Node.js 12 are deprecated [2]. Update the
   following actions to a newer version using Node.js 16:

    - actions/checkout
    - actions/upload-artifact
    - microsoft/setup-msbuild

 * The Github create-release and upload-release-asset actions are no
   longer maintained. Replace with an alternative solution using the
   Github CLI.

[1] https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
[2] https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-11-10 14:02:20 +01:00
Jef Driesen
005a2501b9 Merge branch 'hwos-empty-profile' 2022-11-10 12:38:00 +01:00
Jef Driesen
9508401971 Fix the download of dives without a profile
At the moment, trying to download an old dive for which the profile data
has already been overwritten with newer data fails. This used to work
fine, but around hwOS firmware v3.10, the behaviour described in commit
76187c550a806fe422920eb8795fa687244513f1 changed.

When downloading the compact/full headers, the firmware always sends the
headers without inspecting their content. Next, libdivecomputer uses the
length field in these headers to determine how many bytes to expect when
downloading the dive. However, when downloading the entire dive, the
hwOS firmware now checks whether the profile data of the dive is still
available. If that's no longer the case, the firmware sends a modified
dive header (with the begin/end pointer fields reset to zero, and the
length field reduced to 8 bytes), along with an empty dive profile.
Since libdivecomputer expects to receive the full profile as indicated
in the original header, the download fails with a timeout.

To workaround this problem, download the dive data in two steps. First,
download the 256 byte header and check whether it has been modified. If
that's the case, reduce the length to that of the 5 byte empty profile.

The header check is also updated to exclude the modified fields. For the
progress events, just pretend the full profile has been downloaded.
2022-11-10 11:28:38 +01:00
Jef Driesen
89ae8b94cf Fix the detection of empty dive profiles
Not only the two byte end-of-profile marker 0xFDFD is a valid empty dive
profile, but also a profile with the length field present and set to 8
bytes. In that case the actual length will be just 5 bytes.
2022-11-09 14:27:37 +01:00
Jef Driesen
a99d990117 Verify the fields of the compact header
When downloading the compact headers (which is the default for recent
hwOS firmware), it's not possible to compare the entire dive header, but
we can at least the check the fields that are available.

Also return an error if the verification fails.
2022-11-09 14:27:34 +01:00
Jef Driesen
c578e0a158 Use symbolic constants for the header offsets 2022-11-09 14:24:09 +01:00
Jef Driesen
34bc6b1613 Use the macro for encoding firmware versions
This makes it a bit easer to quickly locate the workarounds for specific
firmware versions.
2022-11-09 14:23:58 +01:00
Greg McLaughlin
59dd6a2a56 Increase the memory size for the Aqualung i770R
The Aqualung i770R appears to have 6M instead of 4M (high) memory.
Confirmed by trying to read past the 6M limit, which fails with a NAK
response. This amount also matches with the capacity stated in the
manual (6553 hours of profile data at a 60 second sample rate).
2022-11-02 22:56:53 +01:00
Jef Driesen
3d388a0a96 Don't pass a NULL pointer to memcpy
The memcpy and related functions expects a valid pointer, even if the
size is zero. Most libc implementations will handle a NULL pointer just
fine, but that's not guaranteed.

Simply skip the call when there is nothing to copy.
2022-11-02 13:23:14 +01:00
Jef Driesen
c5813d624a Add support for the Scubapro G2 TEK
The Scubapro G2 TEK is compatible with the G2, but with a new model
number.

Reported-by: Greg McLaughlin <support@moremobilesoftware.com>
2022-10-16 23:15:54 +02:00
Jef Driesen
3eedf4d24d Use the value stored in the dive header
The maximum depth value is stored in the dive header. There is no need
to parse the profile data to obtain it. This also avoids returning a
zero depth when the profile data is no longer available.

A few other fields (e.g. average depth, atmospheric pressure and
temperature) are also present in the dive header.
2022-10-13 20:56:59 +02:00
Jef Driesen
3e5282bf74 Add support for the Scorpena Alpha
The Scorpena Alpha uses the same communication protocol and data format
as the Deep Six Excursion.

Reported-by: Sven Knoch <info@divinglog.de>
2022-10-11 11:41:12 +02:00
Jef Driesen
ce578cafb9 Report the dive mode for Air and Nitrox dives
Currently the dive mode is only reported for rebreather dives.
2022-08-11 18:26:52 +02: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
Jef Driesen
18f06ea585 Add a macro for the default density and atmospheric pressure
Replace the hardcoded default values with a macro defined in a central
location. This makes it much easier to adjust the values if necessary.
2022-08-11 17:36:15 +02:00
Jef Driesen
7fb943ae7f Add support for parsing the decompression model
Report the decompression algorithm (Buhlmann, VPM, RGBM or DCIEM), and
if available also the parameters. For now only the conservatism setting
is supported, and for the Buhlmann algorithm also the Gradient Factors
(GF).
2022-08-11 17:35:03 +02:00
Jef Driesen
95f309a1c9 Add support for the Cressi Donatello
The Cressi Donatello appears to be compatible with the Goa, with just a
different model number.
2022-08-02 09:03:33 +02:00
Jef Driesen
391d4db419 Add support for the Ratio iX3M 2 models
The protocol and data structures have not changed, so just adding the
new names and model numbers.
2022-07-22 00:27:30 +02:00
Jef Driesen
972beb52be Add support for the Sherwood Amphos Air 2.0
The Amphos Air 2.0 appears to be identical to the previous Amphos Air,
except for the new model number and version string.
2022-07-15 22:14:33 +02:00
Jef Driesen
80f22dce0b Replace switch statements with an array lookup
No functional change, just some more compact code.
2022-07-15 22:11:24 +02:00
Dirk Hohndel
26c43d6d8b Add Shearwater Perdix 2 and Petrel 3
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-27 15:08:35 +02:00
Dirk Hohndel
8451286c17 Update the Shearwater hardware IDs
Update and fix the hardware IDs based on the latest information from
Shearwater.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2022-06-27 15:02:51 +02:00
Jef Driesen
be5bb9e690 Fix the clock synchronization
For dives with a timestamp that is larger than the current device time
(e.g. in the future), the clock synchronization produces incorrect
values. In that case, the time difference suddenly becomes negative,
which corresponds to a large positive value as an unsigned integer.

Under normal circumstances, this scenario can't happen. But sometimes
actions such as battery replacements or firmware upgrades can cause the
internal clock to reset.

The Reefnet devices shouldn't need this fix, because their internal
clock can't be changed, but it doesn't hurt either.
2022-06-23 15:57:08 +02: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
Jef Driesen
4616e2ed21 Add support for a new Aqualung i200C variant
There is a new variant of the i200C with a different model number
(0x4749) and double the amount of memory (128K).
2022-06-19 20:56:14 +02:00
Jef Driesen
4b4efb2c07 Add support for the Seac Screen and Action 2022-06-02 11:29:32 +02:00
Jef Driesen
2443d3ea47 Add an address parameter to the memory dump helper function
To support devices where not all memory is readable, the memory dump
helper function needs an extra parameter to specify the start address.
2022-06-01 13:27:13 +02:00
Jef Driesen
d0c7562c41 Ignore invalid gas mixes
The Cressi Michelangelo appears to store inactive gas mixes as a zero
oxygen percentage. Such invalid values shouldn't be reported.
2022-06-01 09:16:23 +02:00
Jef Driesen
0064097c03 Add support for the Cressi Michelangelo
The Cressi Michelangelo appears to be compatible with the Goa, with just
a different model number.
2022-05-23 12:54:44 +02:00
Jef Driesen
8bfb965589 Move the C_ARRAY_SIZE macro to a common place 2022-05-23 12:14:00 +02:00
Jef Driesen
82c0134811 Fix the timezone offset in the xml output
For negative timezone offsets, only the hour part should have a sign.
The minute part must always be formatted as a positive number.
2022-05-23 12:13:49 +02:00
Jef Driesen
4512a0a5d7 Emit a devinfo event when downloading a memory dump
For diagnostics purposes it's often very useful to have the device
information available when downloading a memory dump.
2022-05-23 12:01:42 +02:00
Jef Driesen
52d2684479 Read the info and more info data during startup 2022-05-23 12:01:38 +02:00
Jef Driesen
7e3bf7eeb8 Use helper functions to decode multibyte values
Add and use some helper functions for decoding multibyte BCD and binary
encoded values, to remove some code duplication.
2022-05-23 12:00:35 +02:00
Jef Driesen
0753f10661 Fix changing the OSTC settings
The command to change the OSTC settings has a variable length payload (1
to 4 bytes). Therefore, the expected number of bytes is only know after
evaluating the first option index byte. Due to the limited UART buffer
in the OSTC, sending the remainder of the packet immediately after the
first byte, can cause the OSTC to get out of sync.

Introduce a small delay between sending the option index and the
remaining parameters to avoid this problem.
2022-03-31 13:20:13 +02:00
Nick Shore
0448ce686a Fix the Genesis React Pro serial number 2022-03-27 10:51:08 +02:00
Jef Driesen
bedd6180f1 Merge branch 'shearwater' 2022-02-27 11:55:10 +01:00
Jef Driesen
c6640aa7d3 Read the extra tank information
The latest firmware does store some additional information for each
tank. Right now it's not really used for anything yet, but it's
available for future use.
2022-02-27 11:49:53 +01:00
Jef Driesen
7a650f940c Add support for transmitter T3 and T4
In recent firmware versions (log version 13), Shearwater added support
for two more tank transmittors: T3 and T4.
2022-02-27 11:48:41 +01:00
Jef Driesen
86e1d59a6a Limit the number of records for the Predator
In the older Predator-like data format, the 4th opening/closing record
is the last one. To avoid accidental use of the higher ones, leave them
undefined.
2022-02-27 11:47:13 +01:00
Jef Driesen
54fa676e75 Report the timezone offset for the Teric
The Shearwater Teric supports a UTC offset and DST setting.
2022-02-27 11:46:51 +01:00
Jef Driesen
d1242a28cf Use the correct model number from the final block
During the download, the model number is obtained from the hardware type
because the model number isn't available before downloading the first
dive. Since the list with available hardware types is incomplete, the
correct model number is not always available. However, during parsing
the correct model number is available in the final block.
2022-02-27 11:45:26 +01:00