[PATCH] Limited support for Suunto DM4 import

Dirk Hohndel dirk at hohndel.org
Sun Mar 3 07:51:42 PST 2013


Miika Turkia <miika.turkia at gmail.com> writes:

> Basic functionality is implemented but at least support for multiple
> cylinders and events is currently missing.
>
> Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
> ---
>  Makefile    |   10 ++++-
>  dive.h      |    2 +
>  file.c      |   20 +++++++++
>  gtk-gui.c   |    5 +++
>  parse-xml.c |  130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 165 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 71e19f0..65932b5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -6,6 +6,7 @@ INSTALL=install
>  PKGCONFIG=pkg-config
>  XML2CONFIG=xml2-config
>  XSLCONFIG=xslt-config
> +SQLITECONFIG=pkg-config

why not use $(PKGCONFIG)? Oh yeah, that's what you do below, this
variable isn't referenced anywhere else in the Makefile :-)

> +#ifdef SQLITE3
> +	fmt = strrchr(filename, '.');
> +	if (fmt && !strcasecmp(fmt + 1, "DB")) {
> +		if (!try_to_open_db(filename, &mem, error)) {
> +			free(mem.buffer);
> +			return;
> +		}
> +	}
> +#endif

This puzzles me - maybe I'm missing how this is supposed to work - is
the database name the same as the filename? What happens if the user
renames the file?

> +#ifdef SQLITE3
> +int sde_dive(void *a_param, int argc, char **argv, char **column)

Calling those parameters argc and **argv is playing mental games with
me... somehow those two parameter names have a well defined meaning for
me, so reading the code below completely threw me off... :-)

> +{
> +	int i;
> +	float *profileBlob;
> +	unsigned char *tempBlob;
> +	int *pressureBlob;
> +	time_t when;
> +	struct tm *tm;
> +	int interval;
> +
> +	dive_start();
> +	cur_dive->number = atoi(argv[0]);
> +
> +	/* Suunto saves time in 100 nano seconds, we'll need the time in

SERIOUSLY? They are clearly completely on drugs.

> +	 * seconds.
> +	 */
> +	when = (time_t)(atol(argv[1]) / 10000000);
> +	tm = localtime(&when);
> +
> +	/* Suunto starts counting time in year 1, we need epoch */

But why stop there? Don't they want to record dives for Hannibal as
well?

> +	/*
> +	 * DM4 stores Duration and DiveTime. It looks like DiveTime is
> +	 * 10 to 60 seconds shorter than Duration. However, I have no
> +	 * idea what is the difference and which one should be used.
> +	 */

Looking at actual profiles it's often easy to figure these things
out. It could be that Duration is the time the computer is "on" or "wet"
while DiveTime is the time below a certain depth...


Thanks for the patch. As I want to cut 3.0.1 tonight I'll hold off on
applying it. Maybe you can make an old man happy and change the
variables from argc/argv to something else. :-)

/D


More information about the subsurface mailing list