Skip to content

Commit bce4420

Browse files
committed
Update libdivecomputer to latest from upstream.
Signed-off-by: Michael Keller <[email protected]>
2 parents 64ecef5 + b09c8d9 commit bce4420

24 files changed

+473
-145
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ jobs:
2525
sudo apt-get update
2626
sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
2727
- run: autoreconf --install --force
28-
- run: ./configure --prefix=/usr
28+
- run: ./configure
2929
- run: make
3030
- run: make distcheck
3131
- name: Package artifacts
3232
run: |
3333
make install DESTDIR=$PWD/artifacts
34-
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
34+
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr/local
3535
- uses: actions/upload-artifact@v4
3636
with:
3737
name: ${{ github.job }}-${{ matrix.compiler }}
@@ -56,13 +56,13 @@ jobs:
5656
- name: Install dependencies
5757
run: brew install autoconf automake libtool hidapi libusb
5858
- run: autoreconf --install --force
59-
- run: ./configure --prefix=/usr
59+
- run: ./configure
6060
- run: make
6161
- run: make distcheck
6262
- name: Package artifacts
6363
run: |
6464
make install DESTDIR=$PWD/artifacts
65-
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
65+
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr/local
6666
- uses: actions/upload-artifact@v4
6767
with:
6868
name: ${{ github.job }}-${{ matrix.compiler }}
@@ -82,7 +82,9 @@ jobs:
8282
steps:
8383
- uses: actions/checkout@v4
8484
- name: Install dependencies
85-
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
85+
run: |
86+
sudo apt-get update
87+
sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
8688
- name: Install libusb
8789
env:
8890
LIBUSB_VERSION: 1.0.26
@@ -91,7 +93,7 @@ jobs:
9193
tar xzf v${LIBUSB_VERSION}.tar.gz
9294
pushd libusb-${LIBUSB_VERSION}
9395
autoreconf --install --force
94-
./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
96+
./configure --host=${{ matrix.arch }}-w64-mingw32
9597
make
9698
make install DESTDIR=$PWD/../artifacts
9799
popd
@@ -103,14 +105,14 @@ jobs:
103105
tar xzf hidapi-${HIDAPI_VERSION}.tar.gz
104106
pushd hidapi-hidapi-${HIDAPI_VERSION}
105107
autoreconf --install --force
106-
./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr LDFLAGS='-static-libgcc'
108+
./configure --host=${{ matrix.arch }}-w64-mingw32 LDFLAGS='-static-libgcc'
107109
make
108110
make install DESTDIR=$PWD/../artifacts
109111
popd
110112
- run: autoreconf --install --force
111-
- run: ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
113+
- run: ./configure --host=${{ matrix.arch }}-w64-mingw32
112114
env:
113-
PKG_CONFIG_LIBDIR: ${{ github.workspace }}/artifacts/usr/lib/pkgconfig
115+
PKG_CONFIG_LIBDIR: ${{ github.workspace }}/artifacts/usr/local/lib/pkgconfig
114116
PKG_CONFIG_SYSROOT_DIR: ${{ github.workspace }}/artifacts
115117
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS: 1
116118
PKG_CONFIG_ALLOW_SYSTEM_LIBS: 1
@@ -119,7 +121,7 @@ jobs:
119121
- name: Package artifacts
120122
run: |
121123
make install DESTDIR=$PWD/artifacts
122-
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
124+
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr/local
123125
- uses: actions/upload-artifact@v4
124126
with:
125127
name: ${{ github.job }}-${{ matrix.arch }}
@@ -140,18 +142,18 @@ jobs:
140142
# CONFIGURATION: Release
141143
#
142144
# steps:
143-
# - uses: actions/checkout@v3
145+
# - uses: actions/checkout@v4
144146
# - uses: msys2/setup-msys2@v2
145147
# with:
146148
# install: autoconf automake libtool pkg-config make gcc
147149
# - run: |
148150
# autoreconf --install --force
149-
# ./configure --prefix=/usr
151+
# ./configure
150152
# make -C src revision.h
151153
# shell: msys2 {0}
152-
# - uses: microsoft/setup-msbuild@v1
154+
# - uses: microsoft/setup-msbuild@v2
153155
# - run: msbuild -m -p:Platform=${{ matrix.platform }} -p:Configuration=${{ env.CONFIGURATION }} contrib/msvc/libdivecomputer.vcxproj
154-
# - uses: actions/upload-artifact@v3
156+
# - uses: actions/upload-artifact@v4
155157
# with:
156158
# name: ${{ github.job }}-${{ matrix.platform }}
157159
# path: contrib/msvc/${{ matrix.platform }}/${{ env.CONFIGURATION }}/bin
@@ -166,7 +168,7 @@ jobs:
166168
- uses: actions/checkout@v4
167169
- run: |
168170
autoreconf --install --force
169-
./configure --prefix=/usr
171+
./configure
170172
make -C src revision.h
171173
- run: $ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
172174
- uses: actions/upload-artifact@v4

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
- name: Build distribution tarball
2121
id: build
2222
run: |
23+
sudo apt-get update
2324
sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
2425
autoreconf --install --force
2526
./configure

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Versioning.
22
m4_define([dc_version_major],[0])
3-
m4_define([dc_version_minor],[9])
3+
m4_define([dc_version_minor],[10])
44
m4_define([dc_version_micro],[0])
55
m4_define([dc_version_suffix],[devel-Subsurface-NG])
66
m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix]))

contrib/android/Android.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ LOCAL_SRC_FILES := \
8585
src/reefnet_sensusultra_parser.c \
8686
src/ringbuffer.c \
8787
src/seac_screen.c \
88+
src/seac_screen_common.c \
8889
src/seac_screen_parser.c \
8990
src/serial_posix.c \
9091
src/shearwater_common.c \

contrib/msvc/libdivecomputer.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@
253253
<ClCompile Include="..\..\src\reefnet_sensus_parser.c" />
254254
<ClCompile Include="..\..\src\ringbuffer.c" />
255255
<ClCompile Include="..\..\src\seac_screen.c" />
256+
<ClCompile Include="..\..\src\seac_screen_common.c" />
256257
<ClCompile Include="..\..\src\seac_screen_parser.c" />
257258
<ClCompile Include="..\..\src\serial_win32.c" />
258259
<ClCompile Include="..\..\src\shearwater_common.c" />
@@ -370,6 +371,7 @@
370371
<ClInclude Include="..\..\src\reefnet_sensusultra.h" />
371372
<ClInclude Include="..\..\src\revision.h" />
372373
<ClInclude Include="..\..\src\ringbuffer.h" />
374+
<ClInclude Include="..\..\src\seac_screen_common.h" />
373375
<ClInclude Include="..\..\src\seac_screen.h" />
374376
<ClInclude Include="..\..\src\shearwater_common.h" />
375377
<ClInclude Include="..\..\src\shearwater_petrel.h" />

examples/dctool_download.c

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ typedef struct dive_data_t {
5353
dc_buffer_t **fingerprint;
5454
unsigned int number;
5555
dctool_output_t *output;
56+
unsigned int limit;
5657
} dive_data_t;
5758

5859
static int
@@ -96,6 +97,11 @@ dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fing
9697

9798
cleanup:
9899
dc_parser_destroy (parser);
100+
101+
if (divedata->limit > 0 && divedata->number >= divedata->limit) {
102+
return 0;
103+
}
104+
99105
return 1;
100106
}
101107

@@ -146,7 +152,7 @@ event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *us
146152
}
147153

148154
static dc_status_t
149-
download (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const char *cachedir, dc_buffer_t *fingerprint, dctool_output_t *output)
155+
download (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const char *cachedir, dc_buffer_t *fingerprint, dctool_output_t *output, unsigned int limit)
150156
{
151157
dc_status_t rc = DC_STATUS_SUCCESS;
152158
dc_iostream_t *iostream = NULL;
@@ -214,6 +220,7 @@ download (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t tra
214220
divedata.fingerprint = &ofingerprint;
215221
divedata.number = 0;
216222
divedata.output = output;
223+
divedata.limit = limit;
217224

218225
// Download the dives.
219226
message ("Downloading the dives.\n");
@@ -260,10 +267,11 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
260267
const char *filename = NULL;
261268
const char *cachedir = NULL;
262269
const char *format = "xml";
270+
unsigned int limit = 0;
263271

264272
// Parse the command-line options.
265273
int opt = 0;
266-
const char *optstring = "ht:o:p:c:f:u:";
274+
const char *optstring = "ht:o:p:c:f:u:l:";
267275
#ifdef HAVE_GETOPT_LONG
268276
struct option options[] = {
269277
{"help", no_argument, 0, 'h'},
@@ -273,6 +281,7 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
273281
{"cache", required_argument, 0, 'c'},
274282
{"format", required_argument, 0, 'f'},
275283
{"units", required_argument, 0, 'u'},
284+
{"limit", required_argument, 0, 'l'},
276285
{0, 0, 0, 0 }
277286
};
278287
while ((opt = getopt_long (argc, argv, optstring, options, NULL)) != -1) {
@@ -304,6 +313,9 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
304313
if (strcmp (optarg, "imperial") == 0)
305314
units = DCTOOL_UNITS_IMPERIAL;
306315
break;
316+
case 'l':
317+
limit = strtoul (optarg, NULL, 0);
318+
break;
307319
default:
308320
return EXIT_FAILURE;
309321
}
@@ -345,7 +357,7 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
345357
}
346358

347359
// Download the dives.
348-
status = download (context, descriptor, transport, argv[0], cachedir, fingerprint, output);
360+
status = download (context, descriptor, transport, argv[0], cachedir, fingerprint, output, limit);
349361
if (status != DC_STATUS_SUCCESS) {
350362
message ("ERROR: %s\n", dctool_errmsg (status));
351363
exitcode = EXIT_FAILURE;
@@ -375,6 +387,7 @@ const dctool_command_t dctool_download = {
375387
" -c, --cache <directory> Cache directory\n"
376388
" -f, --format <format> Output format\n"
377389
" -u, --units <units> Set units (metric or imperial)\n"
390+
" -l, --limit <number> Maximum number of dives to download\n"
378391
#else
379392
" -h Show help message\n"
380393
" -t <transport> Transport type\n"
@@ -383,6 +396,7 @@ const dctool_command_t dctool_download = {
383396
" -c <directory> Cache directory\n"
384397
" -f <format> Output format\n"
385398
" -u <units> Set units (metric or imperial)\n"
399+
" -l <limit> Maximum number of dives to download\n"
386400
#endif
387401
"\n"
388402
"Supported output formats:\n"

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ libdivecomputer_la_SOURCES = \
7777
liquivision_lynx.h liquivision_lynx.c liquivision_lynx_parser.c \
7878
sporasub_sp2.h sporasub_sp2.c sporasub_sp2_parser.c \
7979
deepsix_excursion.h deepsix_excursion.c deepsix_excursion_parser.c \
80+
seac_screen_common.h seac_screen_common.c \
8081
seac_screen.h seac_screen.c seac_screen_parser.c \
8182
deepblu_cosmiq.h deepblu_cosmiq.c deepblu_cosmiq_parser.c \
8283
oceans_s1_common.h oceans_s1_common.c \

src/array.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,15 @@ array_uint16_le (const unsigned char data[])
302302
((unsigned int) data[1] << 8);
303303
}
304304

305+
float
306+
array_float_le (const unsigned char data[])
307+
{
308+
float result = 0;
309+
unsigned int value = array_uint32_le (data);
310+
memcpy (&result, &value, sizeof(value));
311+
return result;
312+
}
313+
305314
void
306315
array_uint64_be_set (unsigned char data[], const unsigned long long input)
307316
{

src/array.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ array_uint16_be (const unsigned char data[]);
9797
unsigned short
9898
array_uint16_le (const unsigned char data[]);
9999

100+
float
101+
array_float_le (const unsigned char data[]);
102+
100103
void
101104
array_uint64_be_set (unsigned char data[], const unsigned long long input);
102105

src/deepblu_cosmiq_parser.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ deepblu_cosmiq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
191191
unsigned int time = 0;
192192
unsigned int offset = SZ_HEADER;
193193
while (offset + SZ_SAMPLE <= size) {
194+
// Ignore empty samples.
195+
if (array_isequal (data + offset, SZ_SAMPLE, 0xFF)) {
196+
offset += SZ_SAMPLE;
197+
continue;
198+
}
199+
194200
dc_sample_value_t sample = {0};
195201
unsigned int temperature = array_uint16_le(data + offset + 0);
196202
unsigned int depth = array_uint16_le(data + offset + 2);

0 commit comments

Comments
 (0)