Skip to content
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

Update libdivecomputer with changes in upstream as of 20240725 #66

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
811ae7d
Add the deco and rbt samples
morejanus Feb 8, 2023
f5f855d
Discard pressure samples from invalid tanks
jefdriesen Mar 7, 2024
e0cf41a
Add some extra parameter validation
jefdriesen Dec 11, 2023
00b0169
Update the internal state in-place
jefdriesen Dec 11, 2023
9090f71
Add support for reading a ringbuffer forwards
jefdriesen Nov 17, 2023
04fe252
Merge branch 'rbstream'
jefdriesen Mar 14, 2024
1ba7e5c
Fix errors in the ringbuffer operations
jefdriesen Feb 16, 2024
4139509
Use symbolic constants for empty/full ringbuffer
jefdriesen Feb 16, 2024
60a9b88
Merge branch 'ringbuffer'
jefdriesen Mar 14, 2024
aa2dbac
Log the number of skipped bytes
jefdriesen Nov 27, 2023
f42449b
Fix the Aeris 500AI logbook read command
jefdriesen Mar 12, 2024
121c7c1
Swap values 2 and 3 of the pointer mode
jefdriesen Mar 5, 2024
a91a7db
Refactor the function to get the profile pointers
jefdriesen Feb 7, 2024
ae29225
Refactor the code to read the device info
jefdriesen Nov 27, 2023
b9d7684
Refactor the code to read the ringbuffer pointers
jefdriesen Nov 27, 2023
f49af52
Separate the error handling from the size calculation
jefdriesen Mar 5, 2024
4cc0bc2
Support reading the logbook in forward direction
jefdriesen Mar 4, 2024
9070b7d
Log the ringbuffer pointers
jefdriesen Mar 19, 2024
47f6949
Merge branch 'pelagic-refactor'
jefdriesen Mar 20, 2024
8e349d4
Add ioctl's for the bluetooth authentication
jefdriesen Nov 27, 2023
9070da3
Add support for the Aqualung i330R and Apeks DSX
morejanus Feb 8, 2023
6903a66
Update the Github actions
jefdriesen Mar 20, 2024
b8c3a09
Fix a macro redefinition warning
jefdriesen Mar 20, 2024
a86cb92
Add some more details to the error messages
jefdriesen Mar 26, 2024
8745a3b
Fix the Mares usb-serial communication
jefdriesen Mar 26, 2024
dcf842c
Fix the Apeks DSX tank number
jefdriesen Apr 1, 2024
4914f6b
Fix the memory layout of the Oceanic Geo
jefdriesen Apr 21, 2024
89a2842
Increase the BLE packet size
jefdriesen Jan 11, 2024
9a603fa
Use macros to detect the device type
jefdriesen Jan 11, 2024
4516842
Use a new command to read the serial number
jefdriesen Jan 16, 2024
f20d9cb
Refactor the Mares Genius and Horizon parser
jefdriesen Apr 19, 2024
1663997
Add support for the Mares Sirius (and compatible models)
jefdriesen Jul 31, 2023
8fe598e
Merge branch 'sirius'
jefdriesen May 3, 2024
eb4b082
Use a different buffer size for Rx and Tx
jefdriesen May 15, 2024
72a88b1
Fix the date/time with timezone offset
jefdriesen May 20, 2024
fdf41bc
Fix the parsing of Apeks DSX sidemount dives
jefdriesen Jul 1, 2024
bde9ef3
Add a new field to report the GPS location
jefdriesen Nov 2, 2023
b0a5ce7
Add support for the Shearwater Tern TX and Peregrine TX
jefdriesen Jul 21, 2024
52bc6b1
Merge remote-tracking branch 'upstream/master' into update_libdivecom…
mikeller Jul 24, 2024
e5c6848
Fixes to make the changes from upstream build.
mikeller Jul 24, 2024
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
16 changes: 8 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
CC: ${{ matrix.compiler }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
- run: autoreconf --install --force
Expand All @@ -30,7 +30,7 @@ jobs:
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
Expand All @@ -50,7 +50,7 @@ jobs:
CC: ${{ matrix.compiler }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: brew install autoconf automake libtool hidapi libusb
- run: autoreconf --install --force
Expand All @@ -61,7 +61,7 @@ jobs:
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
Expand All @@ -78,7 +78,7 @@ jobs:
arch: [i686, x86_64]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install dependencies
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
- name: Install libusb
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}-${{ matrix.arch }}
path: ${{ github.job }}-${{ matrix.arch }}.tar.gz
Expand Down Expand Up @@ -161,13 +161,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- run: |
autoreconf --install --force
./configure --prefix=/usr
make -C src revision.h
- run: $ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}
path: contrib/android/libs
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Version number
id: version
Expand Down
1 change: 1 addition & 0 deletions contrib/android/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ LOCAL_SRC_FILES := \
src/oceans_s1_parser.c \
src/packet.c \
src/parser.c \
src/pelagic_i330r.c \
src/platform.c \
src/rbstream.c \
src/reefnet_sensus.c \
Expand Down
2 changes: 2 additions & 0 deletions contrib/msvc/libdivecomputer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<ClCompile Include="..\..\src\oceans_s1_parser.c" />
<ClCompile Include="..\..\src\packet.c" />
<ClCompile Include="..\..\src\parser.c" />
<ClCompile Include="..\..\src\pelagic_i330r.c" />
<ClCompile Include="..\..\src\platform.c" />
<ClCompile Include="..\..\src\rbstream.c" />
<ClCompile Include="..\..\src\reefnet_sensus.c" />
Expand Down Expand Up @@ -357,6 +358,7 @@
<ClInclude Include="..\..\src\oceans_s1_common.h" />
<ClInclude Include="..\..\src\packet.h" />
<ClInclude Include="..\..\src\parser-private.h" />
<ClInclude Include="..\..\src\pelagic_i330r.h" />
<ClInclude Include="..\..\src\platform.h" />
<ClInclude Include="..\..\src\rbstream.h" />
<ClInclude Include="..\..\src\reefnet_sensus.h" />
Expand Down
1 change: 1 addition & 0 deletions examples/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static const backend_table_t g_backends[] = {
{"vtpro", DC_FAMILY_OCEANIC_VTPRO, 0x4245},
{"veo250", DC_FAMILY_OCEANIC_VEO250, 0x424C},
{"atom2", DC_FAMILY_OCEANIC_ATOM2, 0x4342},
{"i330r", DC_FAMILY_PELAGIC_I330R, 0x4744},
{"nemo", DC_FAMILY_MARES_NEMO, 0},
{"puck", DC_FAMILY_MARES_PUCK, 7},
{"darwin", DC_FAMILY_MARES_DARWIN, 0},
Expand Down
20 changes: 20 additions & 0 deletions examples/output_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,27 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
break;
fprintf (output->ostream, "<extradata key='%s' value='%s' />\n",
str.desc, str.value);
}

// Parse the GPS location.
message ("Parsing the GPS location.\n");
dc_location_t location = {0};
status = dc_parser_get_field (parser, DC_FIELD_LOCATION, 0, &location);
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
ERROR ("Error parsing the GPS location.");
goto cleanup;
}

if (status != DC_STATUS_UNSUPPORTED) {
fprintf (output->ostream,
"<location>\n"
" <latitude>%.6f<latitude>\n"
" <longitude>%.6f</longitude>\n"
" <altitude>%.2f<altitude>\n"
"</location>\n",
location.latitude,
location.longitude,
convert_depth(location.altitude, output->units));
}

// Parse the sample data.
Expand Down
15 changes: 15 additions & 0 deletions include/libdivecomputer/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ extern "C" {
*/
#define DC_IOCTL_BLE_GET_NAME DC_IOCTL_IOR('b', 0, DC_IOCTL_SIZE_VARIABLE)

/**
* Get the bluetooth authentication PIN code.
*
* The data format is a NULL terminated string.
*/
#define DC_IOCTL_BLE_GET_PINCODE DC_IOCTL_IOR('b', 1, DC_IOCTL_SIZE_VARIABLE)

/**
* Get/set the bluetooth authentication access code.
*
* The data format is a variable sized byte array.
*/
#define DC_IOCTL_BLE_GET_ACCESSCODE DC_IOCTL_IOR('b', 2, DC_IOCTL_SIZE_VARIABLE)
#define DC_IOCTL_BLE_SET_ACCESSCODE DC_IOCTL_IOW('b', 2, DC_IOCTL_SIZE_VARIABLE)

#ifdef __cplusplus
}
#endif /* __cplusplus */
Expand Down
1 change: 1 addition & 0 deletions include/libdivecomputer/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef enum dc_family_t {
DC_FAMILY_OCEANIC_VTPRO = (4 << 16),
DC_FAMILY_OCEANIC_VEO250,
DC_FAMILY_OCEANIC_ATOM2,
DC_FAMILY_PELAGIC_I330R,
/* Mares */
DC_FAMILY_MARES_NEMO = (5 << 16),
DC_FAMILY_MARES_PUCK,
Expand Down
13 changes: 13 additions & 0 deletions include/libdivecomputer/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef enum dc_field_type_t {
DC_FIELD_DIVEMODE,
DC_FIELD_DECOMODEL,
DC_FIELD_STRING,
DC_FIELD_LOCATION,
} dc_field_type_t;

// Make it easy to test support compile-time with "#ifdef DC_FIELD_STRING"
Expand Down Expand Up @@ -279,6 +280,18 @@ typedef struct dc_field_string_t {
const char *value;
} dc_field_string_t;

/*
* GPS Location
*
* The latitude and longitude are in decimal degrees, and the (optional)
* altitude in meters.
*/
typedef struct dc_location_t {
double latitude;
double longitude;
double altitude;
} dc_location_t;

typedef union dc_sample_value_t {
unsigned int time; /* Milliseconds */
double depth;
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ libdivecomputer_la_SOURCES = \
oceanic_atom2.h oceanic_atom2.c oceanic_atom2_parser.c \
oceanic_veo250.h oceanic_veo250.c oceanic_veo250_parser.c \
oceanic_vtpro.h oceanic_vtpro.c oceanic_vtpro_parser.c \
pelagic_i330r.h pelagic_i330r.c \
mares_common.h mares_common.c \
mares_nemo.h mares_nemo.c mares_nemo_parser.c \
mares_puck.h mares_puck.c \
Expand Down
4 changes: 2 additions & 2 deletions src/cochran_commander.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ cochran_commander_profile_size(cochran_commander_device_t *device, cochran_data_
// Corrupt dive, guess the end address
sample_end_address = cochran_commander_guess_sample_end_address(device, data, dive_num);

return ringbuffer_distance(sample_start_address, sample_end_address, 0, device->layout->rb_profile_begin, device->layout->rb_profile_end);
return ringbuffer_distance(sample_start_address, sample_end_address, DC_RINGBUFFER_EMPTY, device->layout->rb_profile_begin, device->layout->rb_profile_end);
}


Expand Down Expand Up @@ -965,7 +965,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
last_start_address = base + array_uint32_le(data.config + layout->cf_last_log );

// Create the ringbuffer stream.
status = dc_rbstream_new (&rbstream, abstract, 1, layout->rbstream_size, layout->rb_profile_begin, layout->rb_profile_end, last_start_address);
status = dc_rbstream_new (&rbstream, abstract, 1, layout->rbstream_size, layout->rb_profile_begin, layout->rb_profile_end, last_start_address, DC_RBSTREAM_BACKWARD);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to create the ringbuffer stream.");
goto error;
Expand Down
8 changes: 4 additions & 4 deletions src/cressi_edy.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
}

// Get the number of logbook items.
unsigned int count = ringbuffer_distance (first, last, 0, layout->rb_logbook_begin, layout->rb_logbook_end) + 1;
unsigned int count = ringbuffer_distance (first, last, DC_RINGBUFFER_EMPTY, layout->rb_logbook_begin, layout->rb_logbook_end) + 1;

// Get the profile pointer.
unsigned int eop = array_uint_le (logbook + layout->config + 2, layout->rb_logbook_size) * SZ_PAGE + layout->rb_profile_begin;
Expand All @@ -457,7 +457,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
}

// Get the profile length.
unsigned int length = ringbuffer_distance (current, previous, 1, layout->rb_profile_begin, layout->rb_profile_end);
unsigned int length = ringbuffer_distance (current, previous, DC_RINGBUFFER_FULL, layout->rb_profile_begin, layout->rb_profile_end);

// Check for a ringbuffer overflow.
if (total + length > layout->rb_profile_end - layout->rb_profile_begin) {
Expand All @@ -481,7 +481,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v

// Create the ringbuffer stream.
dc_rbstream_t *rbstream = NULL;
rc = dc_rbstream_new (&rbstream, abstract, SZ_PAGE, SZ_PACKET, layout->rb_profile_begin, layout->rb_profile_end, eop);
rc = dc_rbstream_new (&rbstream, abstract, SZ_PAGE, SZ_PACKET, layout->rb_profile_begin, layout->rb_profile_end, eop, DC_RBSTREAM_BACKWARD);
if (rc != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to create the ringbuffer stream.");
return rc;
Expand Down Expand Up @@ -510,7 +510,7 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
}

// Get the profile length.
unsigned int length = ringbuffer_distance (current, previous, 1, layout->rb_profile_begin, layout->rb_profile_end);
unsigned int length = ringbuffer_distance (current, previous, DC_RINGBUFFER_FULL, layout->rb_profile_begin, layout->rb_profile_end);

// Move to the begin of the current dive.
offset -= length;
Expand Down
2 changes: 1 addition & 1 deletion src/cressi_leonardo.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#define RB_PROFILE_BEGIN 0x1438
#define RB_PROFILE_END SZ_MEMORY
#define RB_PROFILE_DISTANCE(a,b) ringbuffer_distance (a, b, 0, RB_PROFILE_BEGIN, RB_PROFILE_END)
#define RB_PROFILE_DISTANCE(a,b) ringbuffer_distance (a, b, DC_RINGBUFFER_EMPTY, RB_PROFILE_BEGIN, RB_PROFILE_END)

#define MAXRETRIES 4
#define PACKETSIZE 32
Expand Down
8 changes: 8 additions & 0 deletions src/descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ static const dc_descriptor_t g_descriptors[] = {
{"Aqualung", "i470TC", DC_FAMILY_OCEANIC_ATOM2, 0x4743, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
{"Aqualung", "i200Cv2", DC_FAMILY_OCEANIC_ATOM2, 0x4749, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
{"Oceanic", "Geo Air", DC_FAMILY_OCEANIC_ATOM2, 0x474B, DC_TRANSPORT_SERIAL | DC_TRANSPORT_BLE, dc_filter_oceanic},
/* Pelagic I330R */
{"Apeks", "DSX", DC_FAMILY_PELAGIC_I330R, 0x4741, DC_TRANSPORT_BLE, dc_filter_oceanic},
{"Aqualung", "i330R", DC_FAMILY_PELAGIC_I330R, 0x4744, DC_TRANSPORT_BLE, dc_filter_oceanic},
/* Mares Nemo */
{"Mares", "Nemo", DC_FAMILY_MARES_NEMO, 0, DC_TRANSPORT_SERIAL, NULL},
{"Mares", "Nemo Steel", DC_FAMILY_MARES_NEMO, 0, DC_TRANSPORT_SERIAL, NULL},
Expand Down Expand Up @@ -365,6 +368,8 @@ static const dc_descriptor_t g_descriptors[] = {
{"Shearwater", "Petrel 3", DC_FAMILY_SHEARWATER_PETREL, 10, DC_TRANSPORT_BLE, dc_filter_shearwater},
{"Shearwater", "Perdix 2", DC_FAMILY_SHEARWATER_PETREL, 11, DC_TRANSPORT_BLE, dc_filter_shearwater},
{"Shearwater", "Tern", DC_FAMILY_SHEARWATER_PETREL, 12, DC_TRANSPORT_BLE, dc_filter_shearwater},
{"Shearwater", "Tern TX", DC_FAMILY_SHEARWATER_PETREL, 12, DC_TRANSPORT_BLE, dc_filter_shearwater},
{"Shearwater", "Peregrine TX", DC_FAMILY_SHEARWATER_PETREL, 13, DC_TRANSPORT_BLE, dc_filter_shearwater},
/* Dive Rite NiTek Q */
{"Dive Rite", "NiTek Q", DC_FAMILY_DIVERITE_NITEKQ, 0, DC_TRANSPORT_SERIAL, NULL},
/* Citizen Hyper Aqualand */
Expand Down Expand Up @@ -685,6 +690,7 @@ dc_filter_shearwater (dc_descriptor_t *descriptor, dc_transport_t transport, con
"Perdix 2",
"Teric",
"Peregrine",
"Peregrine TX",
"Tern"
};

Expand Down Expand Up @@ -762,8 +768,10 @@ dc_filter_oceanic (dc_descriptor_t *descriptor, dc_transport_t transport, const
0x4654, // Oceanic Veo 4.0
0x4655, // Sherwood Wisdom 4
0x4656, // Oceanic Pro Plus 4
0x4741, // Apeks DSX
0x4742, // Sherwood Beacon
0x4743, // Aqualung i470TC
0x4744, // Aqualung i330R
0x4749, // Aqualung i200C (newer model)
0x474B, // Oceanic Geo Air
};
Expand Down
4 changes: 4 additions & 0 deletions src/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "oceanic_atom2.h"
#include "oceanic_veo250.h"
#include "oceanic_vtpro.h"
#include "pelagic_i330r.h"
#include "mares_darwin.h"
#include "mares_iconhd.h"
#include "mares_nemo.h"
Expand Down Expand Up @@ -165,6 +166,9 @@ dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descr
case DC_FAMILY_OCEANIC_ATOM2:
rc = oceanic_atom2_device_open (&device, context, iostream, dc_descriptor_get_model (descriptor));
break;
case DC_FAMILY_PELAGIC_I330R:
rc = pelagic_i330r_device_open (&device, context, iostream, dc_descriptor_get_model (descriptor));
break;
case DC_FAMILY_MARES_NEMO:
rc = mares_nemo_device_open (&device, context, iostream);
break;
Expand Down
Loading
Loading