Import: Add Parsing for Divesoft Freedom+ Format Files.

Switch the Divesoft log file importer to use the parser in
libdivecomputer. This adds support for the newer Divesoft Freedom+ log
file format.
Also refactor the OSTCTools log file importer to share common
functionality.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-11-11 15:41:31 +13:00
parent 7f42acfdfb
commit 91d8bfef55
2 changed files with 13 additions and 5 deletions

View file

@ -13,13 +13,22 @@
#include "format.h"
#include "libdivecomputer.h"
// As supplied by Divesoft
static const char divesoft_liberty_serial_prefix[] = "7026";
static const char divesoft_freedom_serial_prefix[] = "7044";
static const char divesoft_freedom_plus_serial_prefix[] = "7273";
// From libdivecomputer
static const int divesoft_liberty_model = 10;
static const int divesoft_freedom_model = 19;
int divesoft_import(const std::unique_ptr<std::vector<unsigned char>> &buffer, struct divelog *log)
{
int model = 0;
if (strncmp((char *)(buffer->data() + 52), "7026", 4) == 0)
model = 10;
else if (strncmp((char *)(buffer->data() + 52), "7044", 4) == 0 || strncmp((char *)(buffer->data() + 52), "7273", 4) == 0)
model = 19;
if (strncmp((char *)(buffer->data() + 52), divesoft_liberty_serial_prefix, 4) == 0)
model = divesoft_liberty_model;
else if (strncmp((char *)(buffer->data() + 52), divesoft_freedom_serial_prefix, 4) == 0 || strncmp((char *)(buffer->data() + 52), divesoft_freedom_plus_serial_prefix, 4) == 0)
model = divesoft_freedom_model;
device_data_t devdata;
int ret = prepare_device_descriptor(model, DC_FAMILY_DIVESOFT_FREEDOM, devdata);
if (ret == 0)

View file

@ -278,7 +278,6 @@ static std::unique_ptr<std::vector<unsigned char>> read_into_buffer(const char *
return NULL;
}
// Open the archive
FILE *archive;
if ((archive = subsurface_fopen(file, "rb")) == NULL) {
report_error(failed_to_read_msg, file);