Skip to content

Update libdivecomputer from Upstream. #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8b60a48
Wait longer before retrying and ignore invalid bytes
jefdriesen Mar 14, 2024
b0c48cc
Add support for the Halcyon Symbios
mikeller Jun 8, 2025
c837b16
Remove some unused variables
jefdriesen Jan 12, 2025
11da5a0
Use the GCC unused attribute to silence warnings
jefdriesen Jan 12, 2025
9e94df6
Remove the duplicated C_ARRAY_SIZE macros
jefdriesen Feb 23, 2025
46a7583
Replace the dc_descriptor_iterator function
jefdriesen Feb 23, 2025
c6acdf3
Mark the descriptor parameter as const
jefdriesen Feb 3, 2025
9442528
Check the descriptor transport in the filter
jefdriesen Feb 3, 2025
be0eb79
Remove the rfcomm filter function
jefdriesen Feb 3, 2025
e141872
Select a bluetooth enabled model as the default
jefdriesen Feb 3, 2025
043face
Verify the checksum in the dive header
jefdriesen Nov 8, 2024
e29f5d9
Read the model number for diagnostics purposes
jefdriesen May 3, 2024
ddbc8b5
Add support for the Puck Lite
jefdriesen Mar 10, 2025
7eb0cc5
Limit the size of the fingerprint to 4 bytes
jefdriesen Mar 24, 2025
fd11873
Include the fingerprint data in the logs
jefdriesen Mar 24, 2025
38fffb1
Ignore zero pressure values
jefdriesen Mar 17, 2025
93a885d
Add support for the average depth
jefdriesen Mar 24, 2025
f0473f5
Fix the decoding of the temperature
jefdriesen Mar 24, 2025
3a4afdf
Fix the active gasmix detection
jefdriesen Mar 25, 2025
e2ad016
Use a layout descriptor with a generic decode function
jefdriesen Mar 25, 2025
10ab01d
Read the payload and trailer byte separately
jefdriesen Mar 18, 2025
6944956
Add support for the Cressi Archimede
jefdriesen Mar 17, 2025
b7aa89b
Add support for time synchronization
jefdriesen Apr 16, 2025
eae0fa2
Add extra debug information to the log
jefdriesen Mar 24, 2025
aa121f8
Add support for a new Sirius header version
jefdriesen May 2, 2025
09051a7
Fix the name of the include guard
jefdriesen Apr 24, 2025
b9f7745
Fix the ppO2 scaling factor
jefdriesen Apr 28, 2025
18c3074
Link the tank to the corresponding gas mix
jefdriesen Apr 29, 2025
a696627
Add support for new record types
jefdriesen Apr 28, 2025
31ab5b0
Update the filter function
jefdriesen May 4, 2025
31275f5
Change the order of the functions
jefdriesen May 5, 2025
5edc563
Rename the prefix functions
jefdriesen May 5, 2025
68a8c2a
Use a case-insensitive comparision
jefdriesen May 5, 2025
9e46a34
Add support for a new Cressi Nepto firmware
jefdriesen Apr 29, 2025
0c98248
Fix the Cressi Nepto filter function
jefdriesen May 14, 2025
7a405fd
Always initialize all fields to zero
jefdriesen May 13, 2025
3002287
Fix the deco stop depth scaling factor
jefdriesen May 13, 2025
dfb8fae
Report the device model number
jefdriesen May 13, 2025
1254cb7
Detect NAK response packets
jefdriesen May 21, 2025
9d8a318
Ignore invalid start bytes
jefdriesen May 26, 2025
6dbb648
Add support for the Seac Tablet
jefdriesen May 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/android/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ LOCAL_SRC_FILES := \
src/divesoft_freedom_parser.c \
src/divesystem_idive.c \
src/divesystem_idive_parser.c \
src/halcyon_symbios.c \
src/halcyon_symbios_parser.c \
src/hdlc.c \
src/hw_frog.c \
src/hw_ostc3.c \
Expand Down
3 changes: 3 additions & 0 deletions contrib/msvc/libdivecomputer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@
<ClCompile Include="..\..\src\divesoft_freedom_parser.c" />
<ClCompile Include="..\..\src\divesystem_idive.c" />
<ClCompile Include="..\..\src\divesystem_idive_parser.c" />
<ClCompile Include="..\..\src\halcyon_symbios.c" />
<ClCompile Include="..\..\src\halcyon_symbios_parser.c" />
<ClCompile Include="..\..\src\hdlc.c" />
<ClCompile Include="..\..\src\hw_frog.c" />
<ClCompile Include="..\..\src\hw_ostc.c" />
Expand Down Expand Up @@ -337,6 +339,7 @@
<ClInclude Include="..\..\src\diverite_nitekq.h" />
<ClInclude Include="..\..\src\divesoft_freedom.h" />
<ClInclude Include="..\..\src\divesystem_idive.h" />
<ClInclude Include="..\..\src\halcyon_symbios.h" />
<ClInclude Include="..\..\src\hdlc.h" />
<ClInclude Include="..\..\src\hw_frog.h" />
<ClInclude Include="..\..\src\hw_ostc.h" />
Expand Down
2 changes: 1 addition & 1 deletion doc/man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MANPAGES = \
dc_descriptor_get_product.3 \
dc_descriptor_get_vendor.3 \
dc_descriptor_get_transports.3 \
dc_descriptor_iterator.3 \
dc_descriptor_iterator_new.3 \
dc_device_close.3 \
dc_device_foreach.3 \
dc_device_open.3 \
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_bluetooth_iterator_new.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ opened with
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
Expand Down
4 changes: 2 additions & 2 deletions doc/man/dc_descriptor_free.3
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
Frees a descriptor usually returned with
.Xr dc_iterator_next 3
as created with
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
It's safe to pass
.Dv NULL
to this function.
.Sh SEE ALSO
.Xr dc_descriptor_iterator 3 ,
.Xr dc_descriptor_iterator_new 3 ,
.Xr dc_iterator_free 3
.Sh AUTHORS
The
Expand Down
4 changes: 2 additions & 2 deletions doc/man/dc_descriptor_get_model.3
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
.In libdivecomputer/descriptor.h
.Ft "unsigned int"
.Fo dc_descriptor_get_model
.Fa "dc_descriptor_t *descriptor"
.Fa "const dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the model number of a dive computer descriptor or 0 if none was
Expand All @@ -40,7 +40,7 @@ defined for the computer.
.Sh RETURN VALUES
This returns the model number or 0 if none exists.
.Sh SEE ALSO
.Xr dc_descriptor_iterator 3
.Xr dc_descriptor_iterator_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_descriptor_get_product.3
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.In libdivecomputer/descriptor.h
.Ft "const char *"
.Fo dc_descriptor_get_product
.Fa "dc_descriptor_t *descriptor"
.Fa "const dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the product
Expand Down
6 changes: 3 additions & 3 deletions doc/man/dc_descriptor_get_transports.3
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
.In libdivecomputer/descriptor.h
.Ft "unsigned int"
.Fo dc_descriptor_get_transports
.Fa "dc_descriptor_t *descriptor"
.Fa "const dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the transports supported by the given
.Fa descriptor .
The
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Sh RETURN VALUES
Returns a union (bitwise OR) of the transports supported by the given
.Fa descriptor .
Expand All @@ -59,7 +59,7 @@ if(transports & DC_TRANSPORT_USBHID) {
}
.Ed
.Sh SEE ALSO
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_descriptor_get_vendor.3
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.In libdivecomputer/descriptor.h
.Ft "const char *"
.Fo dc_descriptor_get_vendor
.Fa "dc_descriptor_t *descriptor"
.Fa "const dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the vendor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
.Dt DC_DESCRIPTOR_ITERATOR 3
.Os
.Sh NAME
.Nm dc_descriptor_iterator
.Nm dc_descriptor_iterator_new
.Nd get all supported dive computers
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft dc_status_t
.Fo dc_descriptor_iterator
.Fo dc_descriptor_iterator_new
.Fa "dc_iterator_t **iterator"
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets all descriptors available to
Expand All @@ -56,7 +57,7 @@ The following iterates over all descriptors, printing the vendor, then
frees the iterator.
It does no error checking.
.Bd -literal
dc_descriptor_iterator(&iter));
dc_descriptor_iterator_new(&iter, context));
while (dc_iterator_next(iter, &desc) == DC_STATUS_SUCCESS) {
printf("%s\en", dc_descriptor_get_vendor(desc));
dc_descriptor_free(desc);
Expand Down
4 changes: 2 additions & 2 deletions doc/man/dc_device_open.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ opened with
a dive computer
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 ,
.Xr dc_descriptor_iterator_new 3 ,
and a
.Fa iostream
opened with a transport specific open function like
Expand All @@ -70,7 +70,7 @@ On success, the
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_descriptor_iterator 3 ,
.Xr dc_descriptor_iterator_new 3 ,
.Xr dc_device_close 3
.Sh AUTHORS
The
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_irda_iterator_new.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ opened with
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_iterator_free.3
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
Frees the iterator
.Fa iterator .
It may be invoked on any iterator type, e.g., one created with
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_serial_iterator_new.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ opened with
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
Expand Down
2 changes: 1 addition & 1 deletion doc/man/dc_usbhid_iterator_new.3
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ opened with
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Xr dc_descriptor_iterator_new 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
Expand Down
4 changes: 2 additions & 2 deletions doc/man/libdivecomputer.3
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ and
.Xr dc_context_set_loglevel 3 .
.It
Find a descriptor for their dive computer by iterating through
.Xr dc_descriptor_iterator 3
.Xr dc_descriptor_iterator_new 3
and searching by name, vendor, or product family.
.It
Find the transport to use for the communication. To determine the supported transports use
Expand Down Expand Up @@ -145,7 +145,7 @@ return
.El
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_descriptor_iterator 3
.Xr dc_descriptor_iterator_new 3
.Xr dc_device_open 3
.Xr dc_parser_new 3
.Sh AUTHORS
Expand Down
5 changes: 3 additions & 2 deletions examples/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static const backend_table_t g_backends[] = {
{"iconhd", DC_FAMILY_MARES_ICONHD, 0x14},
{"ostc", DC_FAMILY_HW_OSTC, 0},
{"frog", DC_FAMILY_HW_FROG, 0},
{"ostc3", DC_FAMILY_HW_OSTC3, 0x0A},
{"ostc3", DC_FAMILY_HW_OSTC3, 0x11},
{"edy", DC_FAMILY_CRESSI_EDY, 0x08},
{"leonardo", DC_FAMILY_CRESSI_LEONARDO, 1},
{"goa", DC_FAMILY_CRESSI_GOA, 2},
Expand All @@ -100,6 +100,7 @@ static const backend_table_t g_backends[] = {
{"cosmiq", DC_FAMILY_DEEPBLU_COSMIQ, 0},
{"s1", DC_FAMILY_OCEANS_S1, 0},
{"freedom", DC_FAMILY_DIVESOFT_FREEDOM, 19},
{"symbios", DC_FAMILY_HALCYON_SYMBIOS, 1},

// Not merged upstream yet
{"descentmk1", DC_FAMILY_GARMIN, 0},
Expand Down Expand Up @@ -260,7 +261,7 @@ dctool_descriptor_search (dc_descriptor_t **out, const char *name, dc_family_t f
dc_status_t rc = DC_STATUS_SUCCESS;

dc_iterator_t *iterator = NULL;
rc = dc_descriptor_iterator (&iterator);
rc = dc_descriptor_iterator_new (&iterator, NULL);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error creating the device descriptor iterator.");
return rc;
Expand Down
2 changes: 1 addition & 1 deletion examples/dctool_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dctool_list_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t

dc_iterator_t *iterator = NULL;
dc_descriptor_t *descriptor = NULL;
dc_descriptor_iterator (&iterator);
dc_descriptor_iterator_new (&iterator, context);
while (dc_iterator_next (iterator, &descriptor) == DC_STATUS_SUCCESS) {
printf ("%s %s\n",
dc_descriptor_get_vendor (descriptor),
Expand Down
2 changes: 2 additions & 0 deletions include/libdivecomputer/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ typedef enum dc_family_t {
DC_FAMILY_OCEANS_S1 = (22 << 16),
/* Divesoft Freedom */
DC_FAMILY_DIVESOFT_FREEDOM = (23 << 16),
/* Halcyon Symbios */
DC_FAMILY_HALCYON_SYMBIOS = (24 << 16),

// Not merged upstream yet
/* Garmin */
Expand Down
19 changes: 12 additions & 7 deletions include/libdivecomputer/descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define DC_DESCRIPTOR_H

#include "common.h"
#include "context.h"
#include "iterator.h"

#ifdef __cplusplus
Expand All @@ -38,11 +39,15 @@ typedef struct dc_descriptor_t dc_descriptor_t;
* Create an iterator to enumerate the supported dive computers.
*
* @param[out] iterator A location to store the iterator.
* @param[in] context A valid device descriptor.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_descriptor_iterator (dc_iterator_t **iterator);
dc_descriptor_iterator_new (dc_iterator_t **iterator, dc_context_t *context);

/* For backwards compatibility */
Copy link
Preview

Copilot AI Jun 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backward compatibility macro may obscure the behavior of the updated function. Consider adding a comment to clarify its intended use or reevaluate its necessity.

Suggested change
/* For backwards compatibility */
/**
* Backward compatibility macro for creating an iterator to enumerate
* supported dive computers. This macro is a shorthand for calling
* dc_descriptor_iterator_new with the second parameter set to NULL.
*
* @param[out] iterator A location to store the iterator.
* @note This macro is intended for legacy code and assumes that the
* context parameter is not required. For new code, it is
* recommended to use dc_descriptor_iterator_new directly to
* explicitly specify the context parameter.
*/

Copilot uses AI. Check for mistakes.

#define dc_descriptor_iterator(iterator) dc_descriptor_iterator_new(iterator, NULL)

/**
* Free the device descriptor.
Expand All @@ -59,7 +64,7 @@ dc_descriptor_free (dc_descriptor_t *descriptor);
* @returns The vendor name of the dive computer on success, or NULL on failure.
*/
const char *
dc_descriptor_get_vendor (dc_descriptor_t *descriptor);
dc_descriptor_get_vendor (const dc_descriptor_t *descriptor);

/**
* Get the product name of the dive computer.
Expand All @@ -69,7 +74,7 @@ dc_descriptor_get_vendor (dc_descriptor_t *descriptor);
* failure.
*/
const char *
dc_descriptor_get_product (dc_descriptor_t *descriptor);
dc_descriptor_get_product (const dc_descriptor_t *descriptor);

/**
* Get the family type of the dive computer.
Expand All @@ -79,7 +84,7 @@ dc_descriptor_get_product (dc_descriptor_t *descriptor);
* on failure.
*/
dc_family_t
dc_descriptor_get_type (dc_descriptor_t *descriptor);
dc_descriptor_get_type (const dc_descriptor_t *descriptor);

/**
* Get the model number of the dive computer.
Expand All @@ -89,7 +94,7 @@ dc_descriptor_get_type (dc_descriptor_t *descriptor);
* failure.
*/
unsigned int
dc_descriptor_get_model (dc_descriptor_t *descriptor);
dc_descriptor_get_model (const dc_descriptor_t *descriptor);

/**
* Get all transports supported by the dive computer.
Expand All @@ -99,7 +104,7 @@ dc_descriptor_get_model (dc_descriptor_t *descriptor);
* success, or DC_TRANSPORT_NONE on failure.
*/
unsigned int
dc_descriptor_get_transports (dc_descriptor_t *descriptor);
dc_descriptor_get_transports (const dc_descriptor_t *descriptor);

/**
* Check if a low-level I/O device matches a supported dive computer.
Expand All @@ -117,7 +122,7 @@ dc_descriptor_get_transports (dc_descriptor_t *descriptor);
* there is no match.
*/
int
dc_descriptor_filter (dc_descriptor_t *descriptor, dc_transport_t transport, const void *userdata);
dc_descriptor_filter (const dc_descriptor_t *descriptor, dc_transport_t transport, const void *userdata);

#ifdef __cplusplus
}
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ libdivecomputer_la_SOURCES = \
oceans_s1_common.h oceans_s1_common.c \
oceans_s1.h oceans_s1.c oceans_s1_parser.c \
divesoft_freedom.h divesoft_freedom.c divesoft_freedom_parser.c \
halcyon_symbios.h halcyon_symbios.c halcyon_symbios_parser.c \
hdlc.h hdlc.c \
packet.h packet.c \
socket.h socket.c \
Expand Down
8 changes: 8 additions & 0 deletions src/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ array_reverse_bits (unsigned char data[], unsigned int size)
}
}

void
array_reverse_nibbles (unsigned char data[], unsigned int size)
{
for (unsigned int i = 0; i < size; ++i) {
unsigned char tmp = data[i];
data[i] = ((tmp & 0xF0) >> 4) | ((tmp & 0x0F) << 4);
}
}

int
array_isequal (const unsigned char data[], unsigned int size, unsigned char value)
Expand Down
4 changes: 4 additions & 0 deletions src/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define ARRAY_H

#define C_ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
#define C_ARRAY_ITEMSIZE(a) (sizeof *(a))

#ifdef __cplusplus
extern "C" {
Expand All @@ -34,6 +35,9 @@ array_reverse_bytes (unsigned char data[], unsigned int size);
void
array_reverse_bits (unsigned char data[], unsigned int size);

void
array_reverse_nibbles (unsigned char data[], unsigned int size);

int
array_isequal (const unsigned char data[], unsigned int size, unsigned char value);

Expand Down
2 changes: 2 additions & 0 deletions src/atomics_cobalt.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ atomics_cobalt_device_open (dc_device_t **out, dc_context_t *context, dc_iostrea
goto error_free;
}

HEXDUMP (context, DC_LOGLEVEL_DEBUG, "Version", device->version, sizeof (device->version));

*out = (dc_device_t*) device;

return DC_STATUS_SUCCESS;
Expand Down
Loading
Loading