Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into sync-with-upstream

Merge upstream libdivecomputer changes from Jef Driesen.

The most notable one is how libdivecomputer no longer sends the
GASCHANGE events, but uses DC_SAMPLE_GASMIX instead.

We still turn it into a SAMPLE_EVENT_GASCHANGE2 event internally in
subsurface, since we want all the normal event handling to trigger.

* 'master' of git://git.libdivecomputer.org/libdivecomputer: (21 commits)
  Document the date/time functions
  Document the public api with man pages
  Add support for the Cressi Drake
  Detect overwritten dive profiles
  Ignore tank pressure if no sensor is attached
  Add support for the tank field
  Add support for the salinity field
  Use the sample interval from the settings
  Update the Aqualung i750TC parser
  Toggle the DTR line during setup
  Implement the read function
  Add doxygen documentation to the build system
  Add support for the Aqualung i750TC
  Fix the Windows version resource build
  Force the dive mode to gauge
  Add support for the dive mode
  Report the initial gas mix on the first sample
  Remove the deprecated gas change events
  Add support for the Hollis DG02.
  Add support for the Oceanic F10.
  ...
This commit is contained in:
Linus Torvalds 2017-01-16 16:01:10 -08:00
commit 71cf0a5c69
67 changed files with 5709 additions and 257 deletions

5
.gitignore vendored
View File

@ -32,6 +32,11 @@ Makefile.in
/stamp-h1
/tags
/doc/doxygen
/doc/doxygen.cfg
/doc/html/
/doc/latex/
/examples/aladin
/examples/atom2
/examples/d9

View File

@ -4,6 +4,10 @@ if ENABLE_EXAMPLES
SUBDIRS += examples
endif
if ENABLE_DOC
SUBDIRS += doc
endif
AM_MAKEFLAGS = -s
ACLOCAL_AMFLAGS = -I m4

View File

@ -1,6 +1,6 @@
# Versioning.
m4_define([dc_version_major],[0])
m4_define([dc_version_minor],[5])
m4_define([dc_version_minor],[6])
m4_define([dc_version_micro],[0])
m4_define([dc_version_suffix],[devel-Subsurface-branch])
m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix]))
@ -53,9 +53,19 @@ AC_ARG_ENABLE([examples],
[], [enable_examples=yes])
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
# Documentation.
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--enable-doc=@<:@yes/no@:>@],
[Build documentation @<:@default=yes@:>@])],
[], [enable_doc=yes])
AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"])
# Checks for programs.
AC_PROG_CC
AC_PROG_CC_C99
AC_CHECK_PROGS([DOXYGEN], [doxygen])
AM_CONDITIONAL([HAVE_DOXYGEN],[test -n "$DOXYGEN"])
# Enable automake silent build rules.
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
@ -159,6 +169,9 @@ AC_CONFIG_FILES([
include/libdivecomputer/version.h
src/Makefile
src/libdivecomputer.rc
doc/Makefile
doc/doxygen.cfg
doc/man/Makefile
examples/Makefile
])
AC_OUTPUT

14
doc/Makefile.am Normal file
View File

@ -0,0 +1,14 @@
SUBDIRS = man
doxygen: doxygen.cfg
if HAVE_DOXYGEN
$(DOXYGEN) $(DOXYFLAGS) $<
touch $@
endif
all-local: doxygen
clean-local:
-$(RM) -rf html latex
CLEANFILES = doxygen

2427
doc/doxygen.cfg.in Normal file

File diff suppressed because it is too large Load Diff

34
doc/man/Makefile.am Normal file
View File

@ -0,0 +1,34 @@
dist_man_MANS = \
dc_buffer_append.3 \
dc_buffer_free.3 \
dc_buffer_get_data.3 \
dc_buffer_get_size.3 \
dc_buffer_new.3 \
dc_buffer_prepend.3 \
dc_context_free.3 \
dc_context_new.3 \
dc_context_set_logfunc.3 \
dc_context_set_loglevel.3 \
dc_datetime_gmtime.3 \
dc_datetime_localtime.3 \
dc_datetime_mktime.3 \
dc_datetime_now.3 \
dc_descriptor_free.3 \
dc_descriptor_get_product.3 \
dc_descriptor_get_vendor.3 \
dc_descriptor_iterator.3 \
dc_device_close.3 \
dc_device_foreach.3 \
dc_device_open.3 \
dc_device_set_cancel.3 \
dc_device_set_events.3 \
dc_device_set_fingerprint.3 \
dc_iterator_free.3 \
dc_iterator_next.3 \
dc_parser_destroy.3 \
dc_parser_get_datetime.3 \
dc_parser_get_field.3 \
dc_parser_new.3 \
dc_parser_samples_foreach.3 \
dc_parser_set_data.3 \
libdivecomputer.3

View File

@ -0,0 +1,61 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_APPEND 3
.Os
.Sh NAME
.Nm dc_buffer_append
.Nd append to a binary buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft int
.Fo dc_buffer_append
.Fa "dc_buffer_t *buffer"
.Fa "const unsigned char data[]"
.Fa "size_t size"
.Fc
.Sh DESCRIPTION
Append
.Fa size
bytes of
.Fa data
into the
.Fa buffer
previously allocated with
.Xr dc_buffer_new 3 .
.Sh RETURN VALUES
Returns non-zero on success or zero on memory exhaustion or if
.Fa buffer
is
.Dv NULL .
.Sh SEE ALSO
.Xr dc_buffer_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

51
doc/man/dc_buffer_free.3 Normal file
View File

@ -0,0 +1,51 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_FREE 3
.Os
.Sh NAME
.Nm dc_buffer_free
.Nd free an resizable binary buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft void
.Fo dc_buffer_free
.Fa "dc_buffer_t *buffer"
.Fc
.Sh DESCRIPTION
Frees a resizable binary buffer created with
.Xr dc_buffer_new 3 .
It's safe to pass
.Dv NULL
to this function.
.Sh SEE ALSO
.Xr dc_buffer_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,64 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_GET_DATA 3
.Os
.Sh NAME
.Nm dc_buffer_get_data
.Nd get the data of a buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft "unsigned char *"
.Fo dc_buffer_get_data
.Fa "dc_buffer_t *buffer"
.Fc
.Sh DESCRIPTION
Get the data used by
.Fa buffer ,
previously allocated with
.Xr dc_buffer_new 3 .
For the buffer size, use
.Xr dc_buffer_get_size 3 .
.Pp
The returned pointer is not valid after subsequent calls to change the
buffer.
.Sh RETURN VALUES
Returns the data or
.Dv NULL
if
.Fa buffer
is
.Dv NULL
or no data has been allocated to the buffer.
.Sh SEE ALSO
.Xr dc_buffer_get_size 3 ,
.Xr dc_buffer_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,59 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_GET_SIZE 3
.Os
.Sh NAME
.Nm dc_buffer_get_size
.Nd get the size used by a buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft size_t
.Fo dc_buffer_get_size
.Fa "dc_buffer_t *buffer"
.Fc
.Sh DESCRIPTION
Get the number of bytes currently used by
.Fa buffer ,
previously allocated with
.Xr dc_buffer_new 3 .
This shouldn't be confused with the capacity, which may be larger.
.Pp
The returned value is not valid after subsequent calls to change the
buffer.
.Sh RETURN VALUES
Returns the number of bytes used, which may be zero, or zero if
.Fa buffer
is
.Dv NULL .
.Sh SEE ALSO
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .
.Xr dc_buffer_new 3

57
doc/man/dc_buffer_new.3 Normal file
View File

@ -0,0 +1,57 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_NEW 3
.Os
.Sh NAME
.Nm dc_buffer_new
.Nd create an resizable binary buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft "dc_buffer_t *"
.Fo dc_buffer_new
.Fa "size_t capacity"
.Fc
.Sh DESCRIPTION
Create a resizable binary buffer of initial size
.Fa capacity ,
which may be zero.
The created buffer must be freed with
.Xr dc_buffer_free 3 .
.Sh RETURN VALUES
Returns a pointer to a
.Vt dc_buffer_t
or
.Dv NULL
on memory exhaustion.
.Sh SEE ALSO
.Xr dc_buffer_free 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,61 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_BUFFER_PREPEND 3
.Os
.Sh NAME
.Nm dc_buffer_prepend
.Nd prepend to a binary buffer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/buffer.h
.Ft int
.Fo dc_buffer_prepend
.Fa "dc_buffer_t *buffer"
.Fa "const unsigned char data[]"
.Fa "size_t size"
.Fc
.Sh DESCRIPTION
Prepend
.Fa size
bytes of
.Fa data
to the beginning of
.Fa buffer
previously allocated with
.Xr dc_buffer_new 3 .
.Sh RETURN VALUES
Returns non-zero on success or zero on memory exhaustion or if
.Fa buffer
is
.Dv NULL .
.Sh SEE ALSO
.Xr dc_buffer_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

54
doc/man/dc_context_free.3 Normal file
View File

@ -0,0 +1,54 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_CONTEXT_FREE 3
.Os
.Sh NAME
.Nm dc_context_free
.Nd free a device-handling context
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/context.h
.Ft dc_status_t
.Fo dc_context_free
.Fa "dc_context_t *context"
.Fc
.Sh DESCRIPTION
Free a context created by
.Xr dc_context_new 3 .
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_OK
on success or if the pointer is
.Dv NULL .
Otherwise, it returns an error code.
.Sh SEE ALSO
.Xr dc_context_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

73
doc/man/dc_context_new.3 Normal file
View File

@ -0,0 +1,73 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_CONTEXT_NEW 3
.Os
.Sh NAME
.Nm dc_context_new
.Nd create a new device-handling context
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/context.h
.Ft dc_status_t
.Fo dc_context_new
.Fa "dc_context_t **context"
.Fc
.Sh DESCRIPTION
Create a context in which dive computers may be queried.
The
.Dq context
supplies logging messages and so on, and may be re-used for multiple
dive computer query sessions.
It is usually passed to
.Xr dc_device_open 3
to query a specific dive computer device.
.Pp
On success, the context must be freed with
.Xr dc_context_free 3 .
You may configure the context with
.Xr dc_context_set_loglevel 3
and
.Xr dc_context_set_logfunc 3 .
This is highly recommended as the default logging behaviour of
.Nm
depends upon compile-time values.
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_OK
on success, in which case
.Fa context
is filled in, or an error code on failure.
.Sh SEE ALSO
.Xr dc_context_free 3 ,
.Xr dc_context_set_logfunc 3 ,
.Xr dc_context_set_loglevel 3 ,
.Xr dc_device_open 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,98 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_CONTEXT_SET_LOGFUNC 3
.Os
.Sh NAME
.Nm dc_context_set_logfunc
.Nd set the logging function for a dive computer context
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/context.h
.Ft typedef void
.Fo (*dc_logfunc_t)
.Fa "dc_context_t *context"
.Fa "dc_loglevel_t loglevel"
.Fa "const char *file"
.Fa "unsigned int line"
.Fa "const char *function"
.Fa "const char *message"
.Fa "void *userdata"
.Fc
.Ft dc_status_t
.Fo dc_context_set_logfunc
.Fa "dc_context_t *context"
.Fa "dc_logfunc_t logfunc"
.Fa "void *userdata"
.Fc
.Sh DESCRIPTION
Set the logging function
.Fa logfunc
associated with a dive computer context.
The logging function is invoked with argument
.Fa userdata
when the log level
.Pq see Xr dc_context_set_loglevel 3
has been exceeded.
.Pp
The
.Fa logfunc
accepts the following values:
.Bl -tag -width Ds
.It Fa context
The context in which it was invoked.
.It Fa loglevel
The level of the log message.
.It Fa file
The source file where the message was raised.
.It Fa line
The source line (from 1) where the message was raised.
.It Fa function
The function that raised the log message.
.It Fa message
The log message itself.
.It Fa userdata
The pointer passed to
.Nm dc_context_set_logfunc .
.El
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_OK
on setting the log level,
.Dv DC_STATUS_INVALIDARGS
if
.Fa context
is
.Dv NULL ,
or another error code on failure.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_context_set_loglevel 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,90 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_CONTEXT_SET_LOGLEVEL 3
.Os
.Sh NAME
.Nm dc_context_set_loglevel
.Nd set the logging level for a dive computer context
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/context.h
.Ft dc_status_t
.Fo dc_context_set_loglevel
.Fa "dc_context_t *context"
.Fa "dc_loglevel_t loglevel"
.Fc
.Sh DESCRIPTION
Set the
.Em minimum
log level required to raise a logging event with the
.Xr dc_context_set_logfunc 3
callback.
Operates on a dive computer context created with
.Xr dc_context_new 3 .
The log levels are ordered as follows:
.Bl -enum
.It
.Dv DC_LOGLEVEL_NONE
.It
.Dv DC_LOGLEVEL_ERROR
.It
.Dv DC_LOGLEVEL_WARNING
.It
.Dv DC_LOGLEVEL_INFO
.It
.Dv DC_LOGLEVEL_DEBUG
.It
.Dv DC_LOGLEVEL_ALL
.El
.Pp
By setting, for exammple,
.Dv DC_LOGLEVEL_INFO ,
all events of
.Dv DC_LOGLEVEL_ERROR ,
.Dv DC_LOGLEVEL_WARNING ,
and
.Dv DC_LOGLEVEL_INFO
will be reported via the callback in
.Xr dc_context_set_logfunc 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_OK
on setting the log level,
.Dv DC_STATUS_INVALIDARGS
if
.Fa context
is
.Dv NULL ,
or another error code on failure.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_context_set_logfunc 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,94 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 11, 2017
.Dt DC_DATETIME_GMTIME 3
.Os
.Sh NAME
.Nm dc_datetime_gmtime
.Nd convert an timestamp to GMT date and time
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/datetime.h
.Ft dc_datetime_t *
.Fo dc_datetime_gmtime
.Fa "dc_datetime_t *result"
.Fa "dc_ticks_t ticks"
.Fc
.Sh DESCRIPTION
Convert an integral timestamp
.Fa ticks
created with
.Xr dc_datetime_now 3
or
.Xr dc_datetime_mktime 3
into a broken-down GMT representation in
.Fa result .
The filled-in value consists of the
.Va year ,
.Va month ,
.Va day ,
.Va hour ,
.Va minute ,
and
.Va second
fields.
.Pp
.Em Note :
unlike in
.Vt "struct tm" ,
the value for
.Va year
is normalised, not less 1900; moreover, the value for
.Va month
is from one, not zero.
.Pp
The
.Nm
function may internally invoke libc's
.Xr gmtime 3 ,
or if available,
.Xr gmtime_r 3 .
.Sh RETURN VALUES
This returns the
.Fa result
pointer on success.
It returns
.Dv NULL
if
.Fa ticks
cannot be sanely converted or if
.Fa result
is
.Dv NULL .
.Sh SEE ALSO
.Xr dc_datetime_localtime 3 ,
.Xr dc_datetime_mktime 3 ,
.Xr dc_datetime_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,94 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 11, 2017
.Dt DC_DATETIME_LOCALTIME 3
.Os
.Sh NAME
.Nm dc_datetime_localtime
.Nd convert an timestamp to local date and time
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/datetime.h
.Ft dc_datetime_t *
.Fo dc_datetime_localtime
.Fa "dc_datetime_t *result"
.Fa "dc_ticks_t ticks"
.Fc
.Sh DESCRIPTION
Convert an integral timestamp
.Fa ticks
created with
.Xr dc_datetime_now 3
or
.Xr dc_datetime_mktime 3
into a broken-down local-time representation in
.Fa result .
The filled-in value consists of the
.Va year ,
.Va month ,
.Va day ,
.Va hour ,
.Va minute ,
and
.Va second
fields.
.Pp
.Em Note :
unlike in
.Vt "struct tm" ,
the value for
.Va year
is normalised, not less 1900; moreover, the value for
.Va month
is from one, not zero.
.Pp
The
.Nm
function may internally invoke libc's
.Xr localtime 3 ,
or if available,
.Xr localtime_r 3 .
.Sh RETURN VALUES
This returns the
.Fa result
pointer on success.
It returns
.Dv NULL
if
.Fa ticks
cannot be sanely converted or if
.Fa result
is
.Dv NULL .
.Sh SEE ALSO
.Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_mktime 3 ,
.Xr dc_datetime_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,59 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 11, 2017
.Dt DC_DATETIME_MKTIME 3
.Os
.Sh NAME
.Nm dc_datetime_mktime
.Nd convert an local date and time to a timestamp
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/datetime.h
.Ft dc_ticks_t
.Fo dc_datetime_mktime
.Fa "const dc_datetime_t *dt"
.Fc
.Sh DESCRIPTION
Convert a broken-down local date and time created with
.Xr dc_datetime_localtime 3
into an integral timestamp.
.Pp
The
.Nm
function may internally invoke libc's
.Xr mktime 3 .
.Sh RETURN VALUES
This returns the integral time-stamp or -1 if the given date and time
may not sanely be converted.
.Sh SEE ALSO
.Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_localtime 3 ,
.Xr dc_datetime_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

55
doc/man/dc_datetime_now.3 Normal file
View File

@ -0,0 +1,55 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 11, 2017
.Dt DC_DATETIME_NOW 3
.Os
.Sh NAME
.Nm dc_datetime_now
.Nd return the current integral timestamp
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/datetime.h
.Ft dc_ticks_t
.Fo dc_datetime_now
.Fc
.Sh DESCRIPTION
Get the current system timestamp as an integral value.
.Pp
The
.Nm
function may invoke libc's
.Xr time 3 .
.Sh RETURN VALUES
This always returns the system time.
.Sh SEE ALSO
.Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_localtime 3 ,
.Xr dc_datetime_mktime 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,54 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DESCRIPTOR_FREE 3
.Os
.Sh NAME
.Nm dc_descriptor_free
.Nd free a dive computer descriptor reference
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft void
.Fo dc_descriptor_free
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Frees a descriptor usually returned with
.Xr dc_iterator_next 3
as created with
.Xr dc_descriptor_iterator 3 .
It's safe to pass
.Dv NULL
to this function.
.Sh SEE ALSO
.Xr dc_descriptor_iterator 3 ,
.Xr dc_iterator_free 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,59 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DESCRIPTOR_GET_PRODUCT 3
.Os
.Sh NAME
.Nm dc_descriptor_get_product
.Nd get the product of a dive computer descriptor
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft "const char *"
.Fo dc_descriptor_get_product
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the product
.Pq e.g., Do D6i Dc for my Suunto
of a dive computer descriptor or
.Dv NULL
if none was declared.
.Sh RETURN VALUES
This returns the nil-terminated product string or
.Dv NULL
if none exists.
.Pp
The returned pointer is not valid after the
.Fa descriptor
has been freed.
.Sh SEE ALSO
.Xr dc_descriptor_get_vendor 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,59 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DESCRIPTOR_GET_VENDOR 3
.Os
.Sh NAME
.Nm dc_descriptor_get_vendor
.Nd get the vendor of a dive computer descriptor
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft "const char *"
.Fo dc_descriptor_get_vendor
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the vendor
.Pq e.g., Dq Suunto
of a dive computer descriptor or
.Dv NULL
if none was declared.
.Sh RETURN VALUES
This returns the nil-terminated vendor string or
.Dv NULL
if none exists.
.Pp
The returned pointer is not valid after the
.Fa descriptor
has been freed.
.Sh SEE ALSO
.Xr dc_descriptor_get_product 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,78 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DESCRIPTOR_ITERATOR 3
.Os
.Sh NAME
.Nm dc_descriptor_iterator
.Nd get all supported dive computers
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft dc_status_t
.Fo dc_descriptor_iterator
.Fa "dc_iterator_t **iterator"
.Fc
.Sh DESCRIPTION
Gets all descriptors available to
.Lb libdivecomputer .
It must be matched with
.Xr dc_iterator_free 3
if the return value is
.Dv DC_STATUS_SUCCESS .
The
.Xr dc_iterator_next 3
function must be used to iterate over the iterator.
You must use
.Xr dc_descriptor_free 3
on the returned descriptor value.
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
and fills in the
.Fa iterator
pointer on success.
.Sh EXAMPLES
The following iterates over all descriptors, printing the vendor, then
frees the iterator.
It does no error checking.
.Bd -literal
dc_descriptor_iterator(&iter));
while (dc_iterator_next(iter, &desc) == DC_STATUS_SUCCESS) {
printf("%s\en", dc_descriptor_get_vendor(desc));
dc_descriptor_free(desc);
}
dc_iterator_free(iter);
.Ed
.Sh SEE ALSO
.Xr dc_descriptor_free 3 ,
.Xr dc_iterator_free 3 ,
.Xr dc_iterator_next 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

58
doc/man/dc_device_close.3 Normal file
View File

@ -0,0 +1,58 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_CLOSE 3
.Os
.Sh NAME
.Nm dc_device_close
.Nd close a dive computer device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft dc_status_t
.Fo dc_device_close
.Fa "dc_device_t *device"
.Fc
.Sh DESCRIPTION
Closes a dive computer device opened with
.Xr dc_device_open 3 .
If
.Fa device
is
.Dv NULL ,
this returns
.Dv DC_STATUS_SUCCESS .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
.Sh SEE ALSO
.Xr dc_device_open 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,84 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_FOREACH 3
.Os
.Sh NAME
.Nm dc_device_foreach
.Nd iterate over dives in a dive computer
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft typedef int
.Fo (*dc_dive_callback_t)
.Fa "const unsigned char *data"
.Fa "unsigned int size"
.Fa "const unsigned char *fingerprint"
.Fa "unsigned int fsize"
.Fa "void *userdata"
.Fc
.Ft dc_status_t
.Fo dc_device_foreach
.Fa "dc_device_t *device"
.Fa "dc_dive_callback_t callback"
.Fa "void *userdata"
.Fc
.Sh DESCRIPTION
Iterate over all dives on
.Fa device
by calling
.Fa callback
with
.Fa userdata .
.Pp
Each dive invokes
.Fa callback
with the dive data, which should be parsed with
.Xr dc_parser_set_data 3 ,
and the binary fingerprint of the dive.
The fingerprint can be used to record the newest dive and stop
processing (on subsequent invocations) when the same dive fingerprint is
encountered.
.Pp
The
.Fa callback
function must return non-zero to continue downloading dives, or zero to
stop.
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
If
.Fa callback
returns zero, this will not be reflected in the return value (usually
.Dv DC_STATUS_SUCCESS ) .
.Sh SEE ALSO
.Xr dc_parser_set_data 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

88
doc/man/dc_device_open.3 Normal file
View File

@ -0,0 +1,88 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_OPEN 3
.Os
.Sh NAME
.Nm dc_device_open
.Nd open a dive computer device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft dc_status_t
.Fo dc_device_open
.Fa "dc_device_t **device"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fa "const char *name"
.Fc
.Sh DESCRIPTION
Open a dive computer device for processing.
Accepts a
.Fa context
opened with
.Xr dc_context_new 3 ,
a dive computer
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 ,
and a platform-specific device
.Fa name
.Po
such as
.Pa /dev/ttyUSBx
on Linux,
.Pa /dev/tty.xxx
on Mac OS X,
.Pa /dev/ttyUx
on the BSDs,
or
.Pa COMx
on Microsoft Windows
.Pc .
.Pp
Upon returning
.Dv DC_STATUS_SUCCESS ,
the
.Fa device
pointer must be freed with
.Xr dc_device_close 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
On success, the
.Fa device
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_descriptor_iterator 3 ,
.Xr dc_device_close 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,79 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_SET_CANCEL 3
.Os
.Sh NAME
.Nm dc_device_set_cancel
.Nd callback to check whether processing should cancel
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft "typedef int"
.Fo "(*dc_cancel_callback_t)"
.Fa "void *userdata"
.Fc
.Ft dc_status_t
.Fo dc_device_set_cancel
.Fa "dc_device_t *device"
.Fa "dc_cancel_callback_t callback"
.Fa "void *userdata"
.Fc
.Sh DESCRIPTION
Provide a function that the underlying
.Fa device
will periodically call to see if it should cancel its processing.
The
.Fa callback
will return zero if the operation should not be cancelled, one if it
should be cancelled.
.Pp
The callback usually checks a value that is set during a signal handling
callback.
For example, one can invoke
.Xr signal 3
to a function that sets a
.Vt "volatile sig_atomic_t"
value checked by the
.Fa callback
handler.
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_UNSUPPORTED
if the
.Fa device
is
.Dv NULL ,
or
.Dv DC_STATUS_SUCCESS
otherwise.
.Sh SEE ALSO
.Xr dc_device_open 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
These manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,125 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_SET_EVENTS 3
.Os
.Sh NAME
.Nm dc_device_set_events
.Nd set events logged during device interaction
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft "typedef void"
.Fo "(*dc_event_callback_t)"
.Fa "dc_device_t *device"
.Fa "dc_event_type_t event"
.Fa "const void *data"
.Fa "void *userdata"
.Fc
.Ft dc_status_t
.Fo dc_device_set_events
.Fa "dc_device_t *device"
.Fa "unsigned int events"
.Fa "dc_event_callback_t callback"
.Fa "void *userdata"
.Fc
.Sh DESCRIPTION
Register a series of event callbacks on a device opened with
.Xr dc_device_open 3 .
Event callbacks are informative messages during device processing passed
to the
.Fa callback
function with an optional argument
.Fa userdata.
.Pp
The
.Fa events
value is a bit-field of events, one of which is passed to the
.Fa callback
as
.Fa event .
The
.Fa data
field will be cast to an event-specific type:
.Bl -tag -width Ds
.It Dv DC_EVENT_WAITING
Indicate that the device is waiting for user input, such as activating
the data transfer mode on the device.
No
.Fa data
is set.
.It Dv DC_EVENT_PROGRESS
Progress metre of the parse.
The
.Fa data
variable is set to a
.Vt dc_event_progress_t ,
with the
.Va current
and
.Va maximum
progress values from which one can compute a percentage.
.It Dv DC_EVENT_DEVINFO
Sets the
.Fa data
value to a
.Vt dc_event_devinfo_t ,
which can be used to acquire the
.Va model ,
.Va firmware ,
and
.Va serial
numbers of the underlying device.
.It Dv DC_EVENT_CLOCK
Report the system (local machine) and device time in epoch seconds.
Fills in
.Fa data
as a
.Va dc_event_clock_t ,
with
.Va devtime
being the device and
.Va systime
being the system time.
See
.Xr time 3 .
.It Dv DC_EVENT_VENDOR
A vendor-specific event filling
.Fa data
as a
.Va dc_event_vendor_t .
.El
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
.Sh SEE ALSO
.Xr dc_device_open 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
These manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,70 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_DEVICE_SET_FINGERPRINT 3
.Os
.Sh NAME
.Nm dc_device_set_fingerprint
.Nd set the last-seen dive fingerprint
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/device.h
.Ft dc_status_t
.Fo dc_device_set_fingerprint
.Fa "dc_device_t *device"
.Fa "const unsigned char data[]"
.Fa "unsigned int size"
.Fc
.Sh DESCRIPTION
Sets the last-seen dive fingerprint on a device opened with
.Xr dc_device_open 3 .
This mechanism is used to only download dives
.Dq newer
.Po
as reported by the dive computer, not necessarily on the calendar
.Pc
than the last seen dive.
.Pp
In general usage, the fingerprint is acquired (and saved) from the first
dive downloaded from a dive computer by
.Xr dc_device_foreach 3 .
In subsequent openings of the device, the fingerprint is set with
.Nm
and, when a dive reports a fingerprint matching that dive, the download
exits before reporting that dive.
.Pq The first fingerprint is saved again for subsequent invocations.
In this way, only the newest dives are reported.
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
if the fingerprint was set or one of several error values on error.
.Sh SEE ALSO
.Xr dc_device_open 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,56 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_ITERATOR_FREE 3
.Os
.Sh NAME
.Nm dc_iterator_free
.Nd frees an iterator
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/iterator.h
.Ft dc_status_t
.Fo dc_iterator_free
.Fa "dc_iterator_t *iterator"
.Fc
.Sh DESCRIPTION
Frees the iterator
.Fa iterator .
It may be invoked on any iterator type, e.g., one created with
.Xr dc_descriptor_iterator 3 .
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
on success (or if
.Fa iterator
is
.Dv NULL )
or other values on failure.
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,55 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_ITERATOR_NEXT 3
.Os
.Sh NAME
.Nm dc_iterator_next
.Nd next element in an iterator
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/iterator.h
.Ft dc_status_t
.Fo dc_iterator_next
.Fa "dc_iterator_t *iterator"
.Fa "void *item"
.Fc
.Sh DESCRIPTION
Fills in
.Fa item
with the next element in the iterator
.Fa iterator ,
which may not be
.Dv NULL .
.Sh RETURN VALUES
This returns
.Dv DC_STATUS_SUCCESS
on success.
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,57 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_DESTROY 3
.Os
.Sh NAME
.Nm dc_parser_destroy
.Nd destroys a single dive parser
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft dc_status_t
.Fo dc_parser_destroy
.Fa "dc_parser_t *parser"
.Fc
.Sh DESCRIPTION
Destroys a parser allocated with
.Xr dc_parser_new 3 .
The
.Fa parser
parameter may be
.Dv NULL ,
in which case it will return with success.
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_OK
on success and another code on failure.
.Sh SEE ALSO
.Xr dc_parser_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,69 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_GET_DATETIME 3
.Os
.Sh NAME
.Nm dc_parser_get_datetime
.Nd extract the date and time from a parsed dive
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft dc_status_t
.Fo dc_parser_get_datetime
.Fa "dc_parser_t *parser"
.Fa "dc_datetime_t *datetime"
.Fc
.Sh DESCRIPTION
Extract the date and time of a dive,
.Fa parser ,
previously initialised with
.Xr dc_parser_set_data 3 .
This returns the broken-down time-stamp of the dive in the local time of
the dive.
.Pp
The
.Nm
function may internally invoke
.Xr dc_datetime_gmtime 3
or
.Xr dc_datetime_localtime 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
if the date and time were retrieved,
.Dv DC_STATUS_UNSUPPORTED
if the date and time are not supported by the device, or other error
messages on further failure.
.Sh SEE ALSO
.Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_localtime 3 ,
.Xr dc_parser_set_data 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,197 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_GET_FIELD 3
.Os
.Sh NAME
.Nm dc_parser_get_field
.Nd extract a field from a parsed dive
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft dc_status_t
.Fo dc_parser_get_field
.Fa "dc_parser_t *parser"
.Fa "dc_field_type_t type"
.Fa "unsigned int flags"
.Fa "void *value"
.Fc
.Sh DESCRIPTION
Extract a field from a dive,
.Fa parser ,
previously initialised with
.Xr dc_parser_set_data 3 .
The
.Fa value
field type depends upon the
.Fa type .
The
.Fa flags
field is ignored for all types but
.Dv DC_FIELD_GASMIX
and
.Dv DC_FIELD_TANK .
.Pp
The
.Fa type
may be one of the following values:
.Bl -tag -width Ds
.It Dv DC_FIELD_DIVETIME
Time (duration) of dive in seconds.
The
.Fa value
must be an
.Vt unsigned int .
.It Dv DC_FIELD_MAXDEPTH
Maximum depth in metres.
The
.Fa value
must be a
.Vt double .
.It Dv DC_FIELD_AVGDEPTH
Average depth (over all samples) in metres.
The
.Fa value
must be a
.Vt double .
.It Dv DC_FIELD_GASMIX_COUNT
Number of different gas mixes used in this dive.
The
.Fa value
must be a
.Vt unsigned int .
.It Dv DC_FIELD_GASMIX
Mixture for a particular gas.
The
.Fa value
must be a
.Vt dc_gasmix_t ,
which has
.Vt double
fields for
.Va oxygen ,
.Va helium ,
and
.Va nitrogen .
These are set to the unit fraction of gas (not percentage).
The
.Fa flags
value is interpreted as the gas mixture index, which must be less than the
value of
.Dv DC_FIELD_GASMIX_COUNT .
.It Dv DC_FIELD_SALINITY
The water salinity as a
.Vt dc_salinity_t
field, which consists of a
.Va type ,
.Dv DC_WATER_FRESH
or
.Dv DC_WATER_SALT ,
and the salinity
.Va density .
.It Dv DC_FIELD_ATMOSPHERIC
Atmospheric pressure in bar.
The
.Fa value
field must be a
.Vt double .
.It Dv DC_FIELD_TEMPERATURE_SURFACE
Air temperature (at the surface) in Celsius.
The
.Fa value
field must be a
.Vt double .
.It Dv DC_FIELD_TEMPERATURE_MINIMUM
Minimum water temperature surface in Celsius.
The
.Fa value
field must be a
.Vt double .
.It Dv DC_FIELD_TEMPERATURE_MAXIMUM
Maximum water temperature in Celsius.
The
.Fa value
field must be a
.Vt double .
.It Dv DC_FIELD_TANK_COUNT
The number of tanks as an
.Vt unsigned int .
.It Dv DC_FIELD_TANK
Tank configuration as a
.Vt dc_tank_t .
This structure consists of a
.Va gasmix ,
which may be retrieved with
.Dv DC_FIELD_GASMIX ;
.Va type ,
the tank volume units as
.Dv DC_TANKVOLUME_NONE ,
.Dv DC_TANKVOLUME_IMPERIAL ,
or
.Dv DC_TANKVOLUME_METRIC ;
.Va volume ,
the tank volume in bar or zero if the tank is
.Dv DC_TANKVOLUME_NONE ;
.Va workpressure ,
the work pressure in bar or zero if
.Dv DC_TANKVOLUME_NONE
and maybe zero if
.Dv DC_TANKVOLUME_METRIC ;
.Va beginpressure
and
.Va endpressure
being the pressures at start and finish in bar.
The
.Fa flags
value is the tank index.
.It Dv DC_FIELD_DIVEMODE
Mode of the dive:
.Dv DC_DIVEMODE_FREEDIVE
for free-diving,
.Dv DC_DIVEMODE_GAUGE
for gauge (i.e., running as a record and not computing, say,
decompression events),
.Dv DC_DIVEMODE_OC
for standard open-circuit diving, and
.Dv DC_DIVEMODE_CC
for closed-circuit
.Dq rebreather
diving.
.El
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
if the field was retrieved,
.Dv DC_STATUS_UNSUPPORTED
if the field is not supported by the device, or other error messages on
further failure.
.Sh SEE ALSO
.Xr dc_parser_set_data 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

82
doc/man/dc_parser_new.3 Normal file
View File

@ -0,0 +1,82 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_NEW 3
.Os
.Sh NAME
.Nm dc_parser_new ,
.Nm dc_parser_new2
.Nd create a parser for a single dive
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft dc_status_t
.Fo dc_parser_new
.Fa "dc_parser_t **parser"
.Fa "dc_device_t *device"
.Fc
.Ft dc_status_t
.Fo dc_parser_new2
.Fa "dc_parser_t **parser"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fa "unsigned int devtime"
.Fa "dc_ticks_t systime"
.Fc
.Sh DESCRIPTION
Creates a parser for a single dive extracted from the dive computer with
.Xr dc_device_foreach 3 .
The parser operates on the data extracted: it does not touch the device
directly to acquire data.
Thus, there are two forms of invocation:
.Nm dc_parser_new ,
which extracts relevant values from the
.Fa device
parameter; and
.Nm dc_parser_new2 ,
which is given device values (model, etc.) directly.
.Pp
After filling in the
.Fa parser
parameter, one usually sets parser data with
.Xr dc_parser_set_data 3 .
The pointer must later be freed with
.Xr dc_parser_destroy 3 .
.Sh RETURN VALUES
These return
.Dv DC_STATUS_OK ,
and fill in the
.Fa parser
pointer on success.
Otherwise, an error is returned.
.Sh SEE ALSO
.Xr dc_device_foreach 3 ,
.Xr dc_parser_destroy 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,196 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_SAMPLES_FOREACH 3
.Os
.Sh NAME
.Nm dc_parser_samples_foreach
.Nd iterate over samples taken during a dive
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft "typedef void"
.Fo "(*dc_sample_callback_t)"
.Fa "dc_sample_type_t type"
.Fa "dc_sample_value_t value"
.Fa "void *userdata"
.Fc
.Ft dc_status_t
.Fo dc_parser_samples_foreach
.Fa "dc_parser_t *parser"
.Fa "dc_sample_callback_t callback"
.Fa "void *userdata"
.Fc
.Sh DESCRIPTION
Extract the samples taken during a dive as previously initialised with
.Xr dc_parser_set_data 3 .
Each sample is passed to
.Fa callback
with the
.Fa type
of the sample and its data
.Fa value .
.Pp
Samples are invoked as a sequence of sample sets.
Each sequence begins with a
.Dv DC_SAMPLE_TIME ,
then a number of sample types in the set.
When the next
.Dv DC_SAMPLE_TIME
is recorded, the sample set may be closed and a new one reopened.
After all samples have been rendered, the last sample set should be
closed.
.Pp
The following sample types may be raised:
.Bl -tag -width Ds
.It Dv DC_SAMPLE_TIME
The time of the sample taken in seconds after the dive began.
Set in the
.Fa time
field.
.It Dv DC_SAMPLE_DEPTH
The depth taken at the sample in metres.
Set in the
.Fa depth
field.
.It Dv DC_SAMPLE_PRESSURE
Tank pressure taken at the sample.
Sets the
.Fa tank
index (see the
.Dv DC_FIELD_TANK_COUNT
in
.Xr dc_parser_get_field 3 )
and the
.Fa pressure
in bar.
.It Dv DC_SAMPLE_TEMPERATURE
Temperature in celsius.
Sets the
.Fa temperature
field.
.It Dv DC_SAMPLE_EVENT
An diving event raised by the computer.
This may have the
.Va type
value of the
.Va event
structure set to
.Dv SAMPLE_EVENT_NONE ,
.Dv SAMPLE_EVENT_DECOSTOP ,
.Dv SAMPLE_EVENT_RBT ,
.Dv SAMPLE_EVENT_ASCENT ,
.Dv SAMPLE_EVENT_CEILING ,
.Dv SAMPLE_EVENT_WORKLOAD ,
.Dv SAMPLE_EVENT_TRANSMITTER ,
.Dv SAMPLE_EVENT_VIOLATION ,
.Dv SAMPLE_EVENT_BOOKMARK ,
.Dv SAMPLE_EVENT_SURFACE ,
.Dv SAMPLE_EVENT_SAFETYSTOP ,
.Dv SAMPLE_EVENT_SAFETYSTOP_VOLUNTARY ,
.Dv SAMPLE_EVENT_SAFETYSTOP_MANDATORY ,
.Dv SAMPLE_EVENT_DEEPSTOP ,
.Dv SAMPLE_EVENT_CEILING_SAFETYSTOP ,
.Dv SAMPLE_EVENT_FLOOR ,
.Dv SAMPLE_EVENT_DIVETIME ,
.Dv SAMPLE_EVENT_MAXDEPTH ,
.Dv SAMPLE_EVENT_OLF ,
.Dv SAMPLE_EVENT_PO2 ,
.Dv SAMPLE_EVENT_AIRTIME ,
.Dv SAMPLE_EVENT_RGBM ,
.Dv SAMPLE_EVENT_HEADING ,
or
.Dv SAMPLE_EVENT_TISSUELEVEL .
.It Dv DC_SAMPLE_RBT
The remaining bottom time in seconds.
Sets the
.Fa rbt
field.
.It Dv DC_SAMPLE_HEARTBEAT
The diver's heartbeet in beats per minute.
Sets the
.Fa heartbeat
field.
.It Dv DC_SAMPLE_BEARING
The diver's bearing in degrees.
Sets the
.Fa bearing
field.
.It Dv DC_SAMPLE_VENDOR
A vendor-specific data field.
.It Dv DC_SAMPLE_SETPOINT
The closed-circuit setpoint (PO2) has changed.
Sets the
.Fa setpoint
value in bar.
.It Dv DC_SAMPLE_PPO2
The partial pressure of oxygen has changed (in bar).
Sets the
.Fa ppo2
field.
.It Dv DC_SAMPLE_CNS
The CNS (central nervous system oxygen toxicity) value as a unit
fraction.
Sets the
.Fa cns
value.
.It Dv DC_SAMPLE_DECO
Decompression phase of
.Fa type
.Dv DC_DECO_NDL
.Pq no decompression limit ,
.Dv DC_DECO_SAFETYSTOP
.Pq the safety stop ,
.Dv DC_DECO_DECOSTOP
.Pq a decompression stop ,
or
.Dv DC_DECO_DEEPSTOP
.Pq a mandatory or suggested deep-stop .
Also sets the
.Fa depth
in metres and the
.Fa time
in seconds.
.It Dv DC_SAMPLE_GASMIX
Switch to a given gas mix index (see the
.Dv DC_FIELD_GASMIX_COUNT
in
.Xr dc_parser_get_field 3 ) .
Sets the
.Fa gasmix
field.
.El
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_OK
on success and another code on failure.
.Sh SEE ALSO
.Xr dc_parser_set_data 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -0,0 +1,65 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DC_PARSER_SET_DATA 3
.Os
.Sh NAME
.Nm dc_parser_set_data
.Nd assigns parse data to a dive parser
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/parser.h
.Ft dc_status_t
.Fo dc_parser_set_data
.Fa "dc_parser_t *parser"
.Fa "const unsigned char *data"
.Fa "unsigned int size"
.Fc
.Sh DESCRIPTION
Assigns the binary sequence
.Fa data
of length
.Fa size
bytes to
.Fa parser ,
which was created with
.Xr dc_parser_new 3 .
How the data is parsed depends upon the values provided to
.Xr dc_parser_new 3 .
The data usually comes from the callback assigned to
.Xr dc_device_foreach 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_OK
on success and another code on failure.
.Sh SEE ALSO
.Xr dc_device_foreach 3 ,
.Xr dc_parser_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
The manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

141
doc/man/libdivecomputer.3 Normal file
View File

@ -0,0 +1,141 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd January 5, 2017
.Dt DIVECOMPUTER 3
.Os
.Sh NAME
.Nm divecomputer
.Nd communicate with dive computers
.Sh LIBRARY
.Lb libdivecomputer
.Sh DESCRIPTION
The
.Nm divecomputer
library is a cross-platform and open source library for communication
with dive computers from various manufacturers.
Systems interfacing with
.Nm divecomputer
must link with
.Fl l Ns Ar divecomputer .
.Pp
A system wishing to query dives in a dive computer generally follows
these steps:
.Bl -enum
.It
Create a new context with
.Xr dc_context_new 3 .
This supplies a parse context: logging, error handling, etc.
Override the values with
.Xr dc_context_set_logfunc 3
and
.Xr dc_context_set_loglevel 3 .
.It
Find a descriptor for their dive computer by iterating through
.Xr dc_descriptor_iterator 3
and searching by name, vendor, or product family.
.It
Open the hardware device to which the dive computer is connected with
.Xr dc_device_open 3 ,
then invoke
.Xr dc_device_set_events 3 ,
.Xr dc_device_set_fingerprint 3 ,
and
.Xr dc_device_set_cancel 3
to set the logging events, last-seen fingerprint, and cancel routine,
respectively.
.It
Iterate over all dives with
.Xr dc_device_foreach 3 .
.It
For each iterated dive, create a new parser with
.Xr dc_parser_new 3
and set the parsed data with
.Xr dc_parser_set_data 3 .
.It
Get attributes of the parsed dive with
.Xr dc_parser_get_field 3 ,
then iterate through the dive's samples (recorded data) with
.Xr dc_parser_samples_foreach 3 .
.El
.Sh RETURN VALUES
Most
.Nm libdivecomputer
functions return with a
.Vt dc_status_t
type with the following possible values:
.Bl -tag -width Ds
.It Dv DC_STATUS_SUCCESS
Completion with success: not an error.
.It Dv DC_STATUS_DONE
End of an iterator: not an error.
.It Dv DC_STATUS_UNSUPPORTED
Feature not implemented or not supported by device.
.Po
The difference depends on the context.
Since
.Nm libdivecomputer
is largely
based on reverse engineering, we often can't even tell them apart.
.Pc
.It Dv DC_STATUS_INVALIDARGS
Invalid parameter.
Usually indicates caller bug.
.It Dv DC_STATUS_NOMEMORY
Out of memory.
.It Dv DC_STATUS_NODEVICE
Device not found.
In this context the device refers to the low-level communication device
(serial, bluetooth, irda, etc), not the dive computer.
In most cases, and especially with serial communication, we can't detect
whether the dive computer is present.
This is always detected indirectly: no response is received, and thus a
timeout error.
.It Dv DC_STATUS_NOACCESS
Access denied (again, to the low-level communication device).
.It Dv DC_STATUS_TIMEOUT
See
.Dv DC_STATUS_NODEVICE .
.It Dv DC_STATUS_IO
Any other I/O error.
.It Dv DC_STATUS_PROTOCOL
Encountered unexpected data in the communication protocol data packets,
e.g., while downloading.
.It Dv DC_STATUS_DATAFORMAT
Encountered unexpected data in the interpretation of data contents,
e.g., while parsing.
.It Dv DC_STATUS_CANCELLED
Returned when the cancel callback requested to cancel the operation.
Note that cancellation is only checked at specific (safe) points, so
it's certainly possible it may not get noticed immediately and still
return
.Dv DC_STATUS_SUCCESS .
.El
.Sh SEE ALSO
.Xr dc_buffer_new 3
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
These manpages were written by
.An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv .

View File

@ -39,6 +39,9 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[]
dc_status_t
cressi_leonardo_parser_create (dc_parser_t **parser, dc_context_t *context);
dc_status_t
cressi_leonardo_parser_create2 (dc_parser_t **parser, dc_context_t *context, unsigned int model);
#ifdef __cplusplus
}
#endif /* __cplusplus */

View File

@ -1,5 +1,5 @@
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
AM_CFLAGS = $(LIBUSB_CFLAGS) $(HIDAPI_CFLAGS) -DENABLE_DEPRECATED
AM_CFLAGS = $(LIBUSB_CFLAGS) $(HIDAPI_CFLAGS)
lib_LTLIBRARIES = libdivecomputer.la
@ -95,7 +95,7 @@ libdivecomputer.exp: libdivecomputer.symbols
$(AM_V_GEN) sed -e '/^$$/d' $< > $@
.rc.lo:
$(AM_V_GEN) $(LIBTOOL) --silent --tag=RC --mode=compile $(RC) $< -o $@
$(AM_V_GEN) $(LIBTOOL) --silent --tag=CC --mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) $< -o $@
libdivecomputer.lo: revision.h

View File

@ -332,15 +332,6 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
}
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int o2 = data[SZ_HEADER + SZ_GASMIX * idx + 4];
unsigned int he = data[SZ_HEADER + SZ_GASMIX * idx + 5];
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix_previous = gasmix;
}

View File

@ -127,6 +127,9 @@ citizen_aqualand_parser_get_field (dc_parser_t *abstract, dc_field_type_t type,
case DC_FIELD_GASMIX_COUNT:
*((unsigned int *) value) = 0;
break;
case DC_FIELD_DIVEMODE:
*((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE;
break;
default:
return DC_STATUS_UNSUPPORTED;
}

View File

@ -501,6 +501,9 @@ cochran_commander_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callb
sample.temperature = (data[layout->start_temp] - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
while (offset < size) {
const unsigned char *s = samples + offset;

View File

@ -218,13 +218,6 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
if (idx != gasmix) {
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = bcd2dec(data[0x17 - idx]);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix = idx;
}
}

View File

@ -45,6 +45,9 @@
#define RB_PROFILE_END SZ_MEMORY
#define RB_PROFILE_DISTANCE(a,b) ringbuffer_distance (a, b, 0, RB_PROFILE_BEGIN, RB_PROFILE_END)
#define MAXRETRIES 4
#define PACKETSIZE 32
typedef struct cressi_leonardo_device_t {
dc_device_t base;
dc_serial_t *port;
@ -52,6 +55,7 @@ typedef struct cressi_leonardo_device_t {
} cressi_leonardo_device_t;
static dc_status_t cressi_leonardo_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size);
static dc_status_t cressi_leonardo_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size);
static dc_status_t cressi_leonardo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer);
static dc_status_t cressi_leonardo_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata);
static dc_status_t cressi_leonardo_device_close (dc_device_t *abstract);
@ -60,13 +64,102 @@ static const dc_device_vtable_t cressi_leonardo_device_vtable = {
sizeof(cressi_leonardo_device_t),
DC_FAMILY_CRESSI_LEONARDO,
cressi_leonardo_device_set_fingerprint, /* set_fingerprint */
NULL, /* read */
cressi_leonardo_device_read, /* read */
NULL, /* write */
cressi_leonardo_device_dump, /* dump */
cressi_leonardo_device_foreach, /* foreach */
cressi_leonardo_device_close /* close */
};
static void
cressi_leonardo_make_ascii (const unsigned char raw[], unsigned int rsize, unsigned char ascii[], unsigned int asize)
{
assert (asize == 2 * (rsize + 3));
// Header
ascii[0] = '{';
// Data
array_convert_bin2hex (raw, rsize, ascii + 1, 2 * rsize);
// Checksum
unsigned short crc = checksum_crc_ccitt_uint16 (ascii + 1, 2 * rsize);
unsigned char checksum[] = {
(crc >> 8) & 0xFF, // High
(crc ) & 0xFF}; // Low
array_convert_bin2hex (checksum, sizeof(checksum), ascii + 1 + 2 * rsize, 4);
// Trailer
ascii[asize - 1] = '}';
}
static dc_status_t
cressi_leonardo_packet (cressi_leonardo_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_device_t *abstract = (dc_device_t *) device;
if (device_is_cancelled (abstract))
return DC_STATUS_CANCELLED;
// Send the command to the device.
status = dc_serial_write (device->port, command, csize, NULL);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the command.");
return status;
}
// Receive the answer of the device.
status = dc_serial_read (device->port, answer, asize, NULL);
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to receive the answer.");
return status;
}
// Verify the header and trailer of the packet.
if (answer[0] != '{' || answer[asize - 1] != '}') {
ERROR (abstract->context, "Unexpected answer header/trailer byte.");
return DC_STATUS_PROTOCOL;
}
// Convert the checksum of the packet.
unsigned char checksum[2] = {0};
array_convert_hex2bin (answer + asize - 5, 4, checksum, sizeof(checksum));
// Verify the checksum of the packet.
unsigned short crc = array_uint16_be (checksum);
unsigned short ccrc = checksum_crc_ccitt_uint16 (answer + 1, asize - 6);
if (crc != ccrc) {
ERROR (abstract->context, "Unexpected answer checksum.");
return DC_STATUS_PROTOCOL;
}
return DC_STATUS_SUCCESS;
}
static dc_status_t
cressi_leonardo_transfer (cressi_leonardo_device_t *device, const unsigned char command[], unsigned int csize, unsigned char answer[], unsigned int asize)
{
unsigned int nretries = 0;
dc_status_t rc = DC_STATUS_SUCCESS;
while ((rc = cressi_leonardo_packet (device, command, csize, answer, asize)) != DC_STATUS_SUCCESS) {
// Automatically discard a corrupted packet,
// and request a new one.
if (rc != DC_STATUS_PROTOCOL && rc != DC_STATUS_TIMEOUT)
return rc;
// Abort if the maximum number of retries is reached.
if (nretries++ >= MAXRETRIES)
return rc;
// Discard any garbage bytes.
dc_serial_sleep (device->port, 100);
dc_serial_purge (device->port, DC_DIRECTION_INPUT);
}
return rc;
}
dc_status_t
cressi_leonardo_device_open (dc_device_t **out, dc_context_t *context, const char *name)
{
@ -108,13 +201,6 @@ cressi_leonardo_device_open (dc_device_t **out, dc_context_t *context, const cha
goto error_close;
}
// Clear the DTR line.
status = dc_serial_set_dtr (device->port, 0);
if (status != DC_STATUS_SUCCESS) {
ERROR (context, "Failed to clear the DTR line.");
goto error_close;
}
// Set the RTS line.
status = dc_serial_set_rts (device->port, 1);
if (status != DC_STATUS_SUCCESS) {
@ -122,6 +208,22 @@ cressi_leonardo_device_open (dc_device_t **out, dc_context_t *context, const cha
goto error_close;
}
// Set the DTR line.
status = dc_serial_set_dtr (device->port, 1);
if (status != DC_STATUS_SUCCESS) {
ERROR (context, "Failed to set the DTR line.");
goto error_close;
}
dc_serial_sleep (device->port, 200);
// Clear the DTR line.
status = dc_serial_set_dtr (device->port, 0);
if (status != DC_STATUS_SUCCESS) {
ERROR (context, "Failed to clear the DTR line.");
goto error_close;
}
dc_serial_sleep (device->port, 100);
dc_serial_purge (device->port, DC_DIRECTION_ALL);
@ -168,6 +270,47 @@ cressi_leonardo_device_set_fingerprint (dc_device_t *abstract, const unsigned ch
return DC_STATUS_SUCCESS;
}
static dc_status_t
cressi_leonardo_device_read (dc_device_t *abstract, unsigned int address, unsigned char data[], unsigned int size)
{
dc_status_t rc = DC_STATUS_SUCCESS;
cressi_leonardo_device_t *device = (cressi_leonardo_device_t *) abstract;
unsigned int nbytes = 0;
while (nbytes < size) {
// Calculate the packet size.
unsigned int len = size - nbytes;
if (len > PACKETSIZE)
len = PACKETSIZE;
// Build the raw command.
unsigned char raw[] = {
(address >> 8) & 0xFF, // High
(address ) & 0xFF, // Low
(len >> 8) & 0xFF, // High
(len ) & 0xFF}; // Low
// Build the ascii command.
unsigned char command[2 * (sizeof (raw) + 3)] = {0};
cressi_leonardo_make_ascii (raw, sizeof (raw), command, sizeof (command));
// Send the command and receive the answer.
unsigned char answer[2 * (PACKETSIZE + 3)] = {0};
rc = cressi_leonardo_transfer (device, command, sizeof (command), answer, 2 * (len + 3));
if (rc != DC_STATUS_SUCCESS)
return rc;
// Extract the raw data from the packet.
array_convert_hex2bin (answer + 1, 2 * len, data, len);
nbytes += len;
address += len;
data += len;
}
return rc;
}
static dc_status_t
cressi_leonardo_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
{
@ -337,6 +480,8 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[]
return DC_STATUS_NOMEMORY;
}
unsigned int previous = 0;
unsigned int remaining = RB_PROFILE_END - RB_PROFILE_BEGIN;
for (unsigned int i = 0; i < count; ++i) {
unsigned int idx = (latest + RB_LOGBOOK_COUNT - i) % RB_LOGBOOK_COUNT;
unsigned int offset = RB_LOGBOOK_BEGIN + idx * RB_LOGBOOK_SIZE;
@ -352,6 +497,24 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[]
return DC_STATUS_DATAFORMAT;
}
if (previous && previous != footer + 2) {
ERROR (abstract->context, "Profiles are not continuous (0x%04x 0x%04x 0x%04x).", header, footer, previous);
free (buffer);
return DC_STATUS_DATAFORMAT;
}
// Check the fingerprint data.
if (device && memcmp (data + offset + 8, device->fingerprint, sizeof (device->fingerprint)) == 0)
break;
// Copy the logbook entry.
memcpy (buffer, data + offset, RB_LOGBOOK_SIZE);
// Calculate the profile address and length.
unsigned int address = header + 2;
unsigned int length = RB_PROFILE_DISTANCE (header, footer) - 2;
if (remaining && remaining >= length + 4) {
// Get the same pointers from the profile.
unsigned int header2 = array_uint16_le (data + footer);
unsigned int footer2 = array_uint16_le (data + header);
@ -361,17 +524,6 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[]
return DC_STATUS_DATAFORMAT;
}
// Calculate the profile address and length.
unsigned int address = header + 2;
unsigned int length = RB_PROFILE_DISTANCE (header, footer) - 2;
// Check the fingerprint data.
if (device && memcmp (data + offset + 8, device->fingerprint, sizeof (device->fingerprint)) == 0)
break;
// Copy the logbook entry.
memcpy (buffer, data + offset, RB_LOGBOOK_SIZE);
// Copy the profile data.
if (address + length > RB_PROFILE_END) {
unsigned int len_a = RB_PROFILE_END - address;
@ -382,9 +534,18 @@ cressi_leonardo_extract_dives (dc_device_t *abstract, const unsigned char data[]
memcpy (buffer + RB_LOGBOOK_SIZE, data + address, length);
}
remaining -= length + 4;
} else {
// No more profile data available!
remaining = 0;
length = 0;
}
if (callback && !callback (buffer, RB_LOGBOOK_SIZE + length, buffer + 8, sizeof (device->fingerprint), userdata)) {
break;
}
previous = header;
}
free (buffer);

View File

@ -31,10 +31,13 @@
#define SZ_HEADER 82
#define DRAKE 6
typedef struct cressi_leonardo_parser_t cressi_leonardo_parser_t;
struct cressi_leonardo_parser_t {
dc_parser_t base;
unsigned int model;
};
static dc_status_t cressi_leonardo_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size);
@ -54,7 +57,7 @@ static const dc_parser_vtable_t cressi_leonardo_parser_vtable = {
dc_status_t
cressi_leonardo_parser_create (dc_parser_t **out, dc_context_t *context)
cressi_leonardo_parser_create2 (dc_parser_t **out, dc_context_t *context, unsigned int model)
{
cressi_leonardo_parser_t *parser = NULL;
@ -68,12 +71,21 @@ cressi_leonardo_parser_create (dc_parser_t **out, dc_context_t *context)
return DC_STATUS_NOMEMORY;
}
parser->model = model;
*out = (dc_parser_t*) parser;
return DC_STATUS_SUCCESS;
}
dc_status_t
cressi_leonardo_parser_create (dc_parser_t **parser, dc_context_t *context)
{
return cressi_leonardo_parser_create2 (parser, context, 0);
}
static dc_status_t
cressi_leonardo_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
{
@ -105,23 +117,33 @@ cressi_leonardo_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datet
static dc_status_t
cressi_leonardo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value)
{
cressi_leonardo_parser_t *parser = (cressi_leonardo_parser_t *) abstract;
if (abstract->size < SZ_HEADER)
return DC_STATUS_DATAFORMAT;
const unsigned char *data = abstract->data;
unsigned int interval = 20;
if (parser->model == DRAKE) {
interval = 1;
}
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
if (value) {
switch (type) {
case DC_FIELD_DIVETIME:
*((unsigned int *) value) = array_uint16_le (data + 0x06) * 20;
*((unsigned int *) value) = array_uint16_le (data + 0x06) * interval;
break;
case DC_FIELD_MAXDEPTH:
*((double *) value) = array_uint16_le (data + 0x20) / 10.0;
break;
case DC_FIELD_GASMIX_COUNT:
if (parser->model == DRAKE) {
*((unsigned int *) value) = 0;
} else {
*((unsigned int *) value) = 1;
}
break;
case DC_FIELD_GASMIX:
gasmix->helium = 0.0;
@ -143,16 +165,39 @@ cressi_leonardo_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, u
static dc_status_t
cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata)
{
cressi_leonardo_parser_t *parser = (cressi_leonardo_parser_t *) abstract;
const unsigned char *data = abstract->data;
unsigned int size = abstract->size;
unsigned int time = 0;
unsigned int interval = 20;
if (parser->model == DRAKE) {
interval = 1;
}
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int gasmix = 0;
unsigned int offset = SZ_HEADER;
while (offset + 2 <= size) {
dc_sample_value_t sample = {0};
if (offset + 4 <= size &&
array_uint16_le (data + offset + 2) == 0xFF00)
{
unsigned int surftime = data[offset] + (data[offset + 1] & 0x07) * 60;
// Time (seconds).
time += surftime;
sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
// Depth (1/10 m).
sample.depth = 0.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
offset += 4;
} else {
unsigned int value = array_uint16_le (data + offset);
unsigned int depth = value & 0x07FF;
unsigned int ascent = (value & 0xC000) >> 14;
@ -166,6 +211,13 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Gas change.
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix;
}
// Ascent rate
if (ascent) {
sample.event.type = SAMPLE_EVENT_ASCENT;
@ -177,6 +229,7 @@ cressi_leonardo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
offset += 2;
}
}
return DC_STATUS_SUCCESS;
}

View File

@ -146,6 +146,7 @@ static const dc_descriptor_t g_descriptors[] = {
{"Oceanic", "Veo 180", DC_FAMILY_OCEANIC_VEO250, 0x4252},
{"Aeris", "XR-2", DC_FAMILY_OCEANIC_VEO250, 0x4255},
{"Sherwood", "Insight", DC_FAMILY_OCEANIC_VEO250, 0x425A},
{"Hollis", "DG02", DC_FAMILY_OCEANIC_VEO250, 0x4352},
/* Oceanic Atom 2.0 */
{"Oceanic", "Atom 1.0", DC_FAMILY_OCEANIC_ATOM2, 0x4250},
{"Aeris", "Epic", DC_FAMILY_OCEANIC_ATOM2, 0x4257},
@ -194,11 +195,13 @@ static const dc_descriptor_t g_descriptors[] = {
{"Oceanic", "OCi", DC_FAMILY_OCEANIC_ATOM2, 0x454B},
{"Aeris", "A300CS", DC_FAMILY_OCEANIC_ATOM2, 0x454C},
{"Beuchat", "Mundial 3", DC_FAMILY_OCEANIC_ATOM2, 0x4550},
{"Oceanic", "F10", DC_FAMILY_OCEANIC_ATOM2, 0x4553},
{"Oceanic", "F11", DC_FAMILY_OCEANIC_ATOM2, 0x4554},
{"Subgear", "XP-Air", DC_FAMILY_OCEANIC_ATOM2, 0x4555},
{"Sherwood", "Vision", DC_FAMILY_OCEANIC_ATOM2, 0x4556},
{"Oceanic", "VTX", DC_FAMILY_OCEANIC_ATOM2, 0x4557},
{"Aqualung", "i300", DC_FAMILY_OCEANIC_ATOM2, 0x4559},
{"Aqualung", "i750TC", DC_FAMILY_OCEANIC_ATOM2, 0x455A},
{"Aqualung", "i450T", DC_FAMILY_OCEANIC_ATOM2, 0x4641},
{"Aqualung", "i550T", DC_FAMILY_OCEANIC_ATOM2, 0x4642},
/* Mares Nemo */
@ -251,6 +254,7 @@ static const dc_descriptor_t g_descriptors[] = {
{"Cressi", "Leonardo", DC_FAMILY_CRESSI_LEONARDO, 1},
{"Cressi", "Giotto", DC_FAMILY_CRESSI_LEONARDO, 4},
{"Cressi", "Newton", DC_FAMILY_CRESSI_LEONARDO, 5},
{"Cressi", "Drake", DC_FAMILY_CRESSI_LEONARDO, 6},
/* Zeagle N2iTiON3 */
{"Zeagle", "N2iTiON3", DC_FAMILY_ZEAGLE_N2ITION3, 0},
{"Apeks", "Quantum X", DC_FAMILY_ZEAGLE_N2ITION3, 0},

View File

@ -261,13 +261,6 @@ diverite_nitekq_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = oxygen[gasmix] | (helium[gasmix] << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix_previous = gasmix;
}

View File

@ -43,6 +43,13 @@
#define EPOCH 1199145600 /* 2008-01-01 00:00:00 */
#define OC 0
#define SCR 1
#define CCR 2
#define GAUGE 3
#define FREEDIVE 4
#define INVALID 0xFFFFFFFF
typedef struct divesystem_idive_parser_t divesystem_idive_parser_t;
struct divesystem_idive_parser_t {
@ -51,6 +58,7 @@ struct divesystem_idive_parser_t {
unsigned int samplesize;
// Cached fields.
unsigned int cached;
unsigned int divemode;
unsigned int divetime;
unsigned int maxdepth;
unsigned int ngasmixes;
@ -105,6 +113,7 @@ divesystem_idive_parser_create2 (dc_parser_t **out, dc_context_t *context, unsig
parser->samplesize = SZ_SAMPLE_IDIVE;
}
parser->cached = 0;
parser->divemode = INVALID;
parser->divetime = 0;
parser->maxdepth = 0;
parser->ngasmixes = 0;
@ -126,6 +135,7 @@ divesystem_idive_parser_set_data (dc_parser_t *abstract, const unsigned char *da
// Reset the cache.
parser->cached = 0;
parser->divemode = INVALID;
parser->divetime = 0;
parser->maxdepth = 0;
parser->ngasmixes = 0;
@ -191,6 +201,28 @@ divesystem_idive_parser_get_field (dc_parser_t *abstract, dc_field_type_t type,
case DC_FIELD_ATMOSPHERIC:
*((double *) value) = array_uint16_le (data + 11) / 1000.0;
break;
case DC_FIELD_DIVEMODE:
if (parser->divemode == 0xFFFFFFFF)
return DC_STATUS_UNSUPPORTED;
switch (parser->divemode) {
case OC:
*((dc_divemode_t *) value) = DC_DIVEMODE_OC;
break;
case SCR:
case CCR:
*((dc_divemode_t *) value) = DC_DIVEMODE_CC;
break;
case GAUGE:
*((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE;
break;
case FREEDIVE:
*((dc_divemode_t *) value) = DC_DIVEMODE_FREEDIVE;
break;
default:
ERROR (abstract->context, "Unknown dive mode %02x.", parser->divemode);
return DC_STATUS_DATAFORMAT;
}
break;
default:
return DC_STATUS_UNSUPPORTED;
}
@ -214,6 +246,8 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
unsigned int helium[NGASMIXES];
unsigned int o2_previous = 0xFFFFFFFF;
unsigned int he_previous = 0xFFFFFFFF;
unsigned int mode_previous = INVALID;
unsigned int divemode = INVALID;
unsigned int offset = parser->headersize;
while (offset + parser->samplesize <= size) {
@ -241,6 +275,18 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.temperature = temperature / 10.0;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
// Dive mode
unsigned int mode = data[offset + 18];
if (mode != mode_previous) {
if (mode_previous != INVALID) {
WARNING (abstract->context, "Dive mode changed from %02x to %02x.", mode_previous, mode);
}
mode_previous = mode;
}
if (divemode == INVALID) {
divemode = mode;
}
// Gaschange.
unsigned int o2 = data[offset + 10];
unsigned int he = data[offset + 11];
@ -266,13 +312,6 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.gasmix = i;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
o2_previous = o2;
he_previous = he;
}
@ -308,6 +347,7 @@ divesystem_idive_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
parser->ngasmixes = ngasmixes;
parser->maxdepth = maxdepth;
parser->divetime = time;
parser->divemode = divemode;
parser->cached = 1;
return DC_STATUS_SUCCESS;

View File

@ -741,16 +741,6 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
if (time == samplerate && parser->initial != UNDEFINED) {
sample.gasmix = parser->initial;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int idx = parser->initial;
unsigned int o2 = parser->gasmix[idx].oxygen;
unsigned int he = parser->gasmix[idx].helium;
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
}
// Depth (mbar).
@ -838,13 +828,6 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset += 2;
length -= 2;
}
@ -863,15 +846,6 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
idx--; /* Convert to a zero based index. */
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int o2 = parser->gasmix[idx].oxygen;
unsigned int he = parser->gasmix[idx].helium;
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset++;
length--;
}
@ -911,13 +885,6 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset += 2;
length -= 2;
}
@ -1023,13 +990,6 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset += 2;
length -= 2;
}

View File

@ -67,6 +67,7 @@ hw_ostc_parser_create
hw_ostc3_parser_create
cressi_edy_parser_create
cressi_leonardo_parser_create
cressi_leonardo_parser_create2
atomics_cobalt_parser_create
atomics_cobalt_parser_set_calibration
shearwater_predator_parser_create

View File

@ -217,8 +217,15 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
unsigned int time = 0;
unsigned int mode = abstract->data[0x0C] & 0x03;
unsigned int pressure = array_uint16_be (abstract->data + 0x17);
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int gasmix = gasmix_previous;
if (mode != GAUGE) {
gasmix = 0;
}
unsigned int offset = parser->headersize;
while (offset + parser->samplesize <= abstract->size) {
dc_sample_value_t sample = {0};
@ -238,6 +245,13 @@ mares_darwin_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Gas change.
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix;
}
// Ascent rate
if (ascent) {
sample.event.type = SAMPLE_EVENT_ASCENT;

View File

@ -22,6 +22,7 @@
#include <stdlib.h>
#include <libdivecomputer/mares_iconhd.h>
#include <libdivecomputer/units.h>
#include "context-private.h"
#include "parser-private.h"
@ -35,6 +36,7 @@
#define ICONHDNET 0x15
#define NGASMIXES 3
#define NTANKS NGASMIXES
#define AIR 0
#define GAUGE 1
@ -52,6 +54,10 @@ struct mares_iconhd_parser_t {
unsigned int nsamples;
unsigned int footer;
unsigned int samplesize;
unsigned int settings;
unsigned int interval;
unsigned int samplerate;
unsigned int ntanks;
unsigned int ngasmixes;
unsigned int oxygen[NGASMIXES];
};
@ -133,32 +139,53 @@ mares_iconhd_parser_cache (mares_iconhd_parser_t *parser)
samplesize = 14;
}
// Calculate the total number of bytes for this dive.
unsigned int nbytes = 4 + headersize + nsamples * samplesize;
if (parser->model == ICONHDNET) {
nbytes += (nsamples / 4) * 8;
} else if (parser->model == SMARTAPNEA) {
if (length < headersize) {
ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT;
}
unsigned int settings = array_uint16_le (data + length - headersize + 0x1C);
unsigned int divetime = array_uint32_le (data + length - headersize + 0x24);
unsigned int samplerate = 1 << ((settings >> 9) & 0x03);
nbytes += divetime * samplerate * 2;
}
if (length != nbytes) {
ERROR (abstract->context, "Calculated and stored size are not equal.");
return DC_STATUS_DATAFORMAT;
}
const unsigned char *p = data + length - headersize;
if (parser->model != SMART && parser->model != SMARTAPNEA) {
p += 4;
}
// Get the dive settings.
unsigned int settings = 0;
if (parser->model == SMARTAPNEA) {
settings = array_uint16_le (p + 0x1C);
} else if (parser->mode == FREEDIVE) {
settings = array_uint16_le (p + 0x08);
} else {
settings = array_uint16_le (p + 0x0C);
}
// Get the sample interval.
unsigned int interval = 0;
unsigned int samplerate = 0;
if (parser->model == SMARTAPNEA) {
unsigned int idx = (settings & 0x0600) >> 9;
interval = 1;
samplerate = 1 << idx;
} else {
const unsigned int intervals[] = {1, 5, 10, 20};
unsigned int idx = (settings & 0x0C00) >> 10;
interval = intervals[idx];
samplerate = 1;
}
// Calculate the total number of bytes for this dive.
unsigned int nbytes = 4 + headersize + nsamples * samplesize;
if (parser->model == ICONHDNET) {
nbytes += (nsamples / 4) * 8;
} else if (parser->model == SMARTAPNEA) {
unsigned int divetime = array_uint32_le (p + 0x24);
nbytes += divetime * samplerate * 2;
}
if (length != nbytes) {
ERROR (abstract->context, "Calculated and stored size are not equal.");
return DC_STATUS_DATAFORMAT;
}
// Gas mixes
unsigned int ngasmixes = 0;
unsigned int oxygen[NGASMIXES] = {0};
@ -180,11 +207,27 @@ mares_iconhd_parser_cache (mares_iconhd_parser_t *parser)
}
}
// Tanks
unsigned int ntanks = 0;
if (parser->model == ICONHDNET) {
while (ntanks < NTANKS) {
unsigned int beginpressure = array_uint16_le (p + 0x58 + ntanks * 4 + 0);
unsigned int endpressure = array_uint16_le (p + 0x58 + ntanks * 4 + 2);
if (beginpressure == 0 && (endpressure == 0 || endpressure == 36000))
break;
ntanks++;
}
}
// Cache the data for later use.
parser->mode = mode;
parser->nsamples = nsamples;
parser->footer = length - headersize;
parser->samplesize = samplesize;
parser->settings = settings;
parser->interval = interval;
parser->samplerate = samplerate;
parser->ntanks = ntanks;
parser->ngasmixes = ngasmixes;
for (unsigned int i = 0; i < ngasmixes; ++i) {
parser->oxygen[i] = oxygen[i];
@ -217,6 +260,10 @@ mares_iconhd_parser_create (dc_parser_t **out, dc_context_t *context, unsigned i
parser->nsamples = 0;
parser->footer = 0;
parser->samplesize = 0;
parser->settings = 0;
parser->interval = 0;
parser->samplerate = 0;
parser->ntanks = 0;
parser->ngasmixes = 0;
for (unsigned int i = 0; i < NGASMIXES; ++i) {
parser->oxygen[i] = 0;
@ -239,6 +286,10 @@ mares_iconhd_parser_set_data (dc_parser_t *abstract, const unsigned char *data,
parser->nsamples = 0;
parser->footer = 0;
parser->samplesize = 0;
parser->settings = 0;
parser->interval = 0;
parser->samplerate = 0;
parser->ntanks = 0;
parser->ngasmixes = 0;
for (unsigned int i = 0; i < NGASMIXES; ++i) {
parser->oxygen[i] = 0;
@ -299,7 +350,11 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
p += 4;
}
unsigned int volume = 0, workpressure = 0;
dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
dc_tank_t *tank = (dc_tank_t *) value;
dc_salinity_t *water = (dc_salinity_t *) value;
if (value) {
switch (type) {
@ -315,7 +370,7 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
}
*((unsigned int *) value) = divetime;
} else {
*((unsigned int *) value) = parser->nsamples * 5;
*((unsigned int *) value) = parser->nsamples * parser->interval;
}
break;
case DC_FIELD_MAXDEPTH:
@ -334,6 +389,32 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
gasmix->helium = 0.0;
gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium;
break;
case DC_FIELD_TANK_COUNT:
*((unsigned int *) value) = parser->ntanks;
break;
case DC_FIELD_TANK:
volume = array_uint16_le (p + 0x64 + flags * 8 + 0);
workpressure = array_uint16_le (p + 0x64 + flags * 8 + 2);
if (parser->settings & 0x0100) {
tank->type = DC_TANKVOLUME_METRIC;
tank->volume = volume;
tank->workpressure = workpressure;
} else {
if (workpressure == 0)
return DC_STATUS_DATAFORMAT;
tank->type = DC_TANKVOLUME_IMPERIAL;
tank->volume = volume * CUFT * 1000.0;
tank->volume /= workpressure * PSI / ATM;
tank->workpressure = workpressure * PSI / BAR;
}
tank->beginpressure = array_uint16_le (p + 0x58 + flags * 4 + 0) / 100.0;
tank->endpressure = array_uint16_le (p + 0x58 + flags * 4 + 2) / 100.0;
if (flags < parser->ngasmixes) {
tank->gasmix = flags;
} else {
tank->gasmix = DC_GASMIX_UNKNOWN;
}
break;
case DC_FIELD_ATMOSPHERIC:
// Pressure (1/8 millibar)
if (parser->model == SMARTAPNEA)
@ -343,6 +424,24 @@ mares_iconhd_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
else
*((double *) value) = array_uint16_le (p + 0x22) / 8000.0;
break;
case DC_FIELD_SALINITY:
if (parser->model == SMARTAPNEA) {
unsigned int salinity = parser->settings & 0x003F;
if (salinity == 0) {
water->type = DC_WATER_FRESH;
} else {
water->type = DC_WATER_SALT;
}
water->density = 1000.0 + salinity;
} else {
if (parser->settings & 0x0010) {
water->type = DC_WATER_FRESH;
} else {
water->type = DC_WATER_SALT;
}
water->density = 0.0;
}
break;
case DC_FIELD_TEMPERATURE_MINIMUM:
if (parser->model == SMARTAPNEA)
*((double *) value) = (signed short) array_uint16_le (p + 0x3C) / 10.0;
@ -396,25 +495,18 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
const unsigned char *data = abstract->data;
unsigned int time = 0;
unsigned int interval = 5;
unsigned int samplerate = 1;
if (parser->model == SMARTAPNEA) {
unsigned int settings = array_uint16_le (data + parser->footer + 0x1C);
samplerate = 1 << ((settings >> 9) & 0x03);
if (samplerate > 1) {
if (parser->samplerate > 1) {
// The Smart Apnea supports multiple samples per second
// (e.g. 2, 4 or 8). Since our smallest unit of time is one
// second, we can't represent this, and the extra samples
// will get dropped.
WARNING(abstract->context, "Multiple samples per second are not supported!");
}
interval = 1;
}
// Previous gas mix - initialize with impossible value
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int time = 0;
unsigned int offset = 4;
unsigned int nsamples = 0;
while (nsamples < parser->nsamples) {
@ -439,7 +531,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
for (unsigned int i = 0; i < divetime; ++i) {
// Time (seconds).
time += interval;
time += parser->interval;
sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
@ -448,7 +540,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
offset += 2 * samplerate;
offset += 2 * parser->samplerate;
}
} else if (parser->mode == FREEDIVE) {
unsigned int maxdepth = array_uint16_le (data + offset + 0);
@ -477,7 +569,7 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
nsamples++;
} else {
// Time (seconds).
time += interval;
time += parser->interval;
sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
@ -492,8 +584,8 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
// Current gas mix
if (parser->ngasmixes > 0) {
unsigned int gasmix = (data[offset + 3] & 0xF0) >> 4;
if (parser->ngasmixes > 0) {
if (gasmix >= parser->ngasmixes) {
ERROR (abstract->context, "Invalid gas mix index.");
return DC_STATUS_DATAFORMAT;
@ -501,12 +593,6 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE;
sample.event.time = 0;
sample.event.value = parser->oxygen[gasmix];
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix_previous = gasmix;
}
}
@ -517,10 +603,16 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
// Some extra data.
if (parser->model == ICONHDNET && (nsamples % 4) == 0) {
// Pressure (1/100 bar).
if (parser->ntanks > 0) {
unsigned int pressure = array_uint16_le(data + offset);
sample.pressure.tank = 0;
if (gasmix >= parser->ntanks) {
ERROR (abstract->context, "Invalid tank index.");
return DC_STATUS_DATAFORMAT;
}
sample.pressure.tank = gasmix;
sample.pressure.value = pressure / 100.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata);
}
offset += 8;
}

View File

@ -358,6 +358,13 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
pressure = array_uint16_le(p + parser->header + 4);
}
// Initial gas mix.
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int gasmix = gasmix_previous;
if (parser->mode == AIR || parser->mode == NITROX) {
gasmix = 0;
}
unsigned int time = 0;
for (unsigned int i = 0; i < parser->sample_count; ++i) {
dc_sample_value_t sample = {0};
@ -378,6 +385,13 @@ mares_nemo_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Gas change.
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix;
}
// Ascent rate
if (ascent) {
sample.event.type = SAMPLE_EVENT_ASCENT;

View File

@ -35,6 +35,7 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &oceanic_atom2_device_vtable.base)
#define VTX 0x4557
#define I750TC 0x455A
#define MAXRETRIES 2
#define MAXDELAY 16
@ -82,6 +83,7 @@ static const oceanic_common_device_vtable_t oceanic_atom2_device_vtable = {
static const oceanic_common_version_t aeris_f10_version[] = {
{"FREEWAER \0\0 512K"},
{"OCEANF10 \0\0 512K"},
{"MUNDIAL R\0\0 512K"},
};
@ -182,6 +184,7 @@ static const oceanic_common_version_t oceanic_reactpro_version[] = {
static const oceanic_common_version_t aeris_a300cs_version[] = {
{"AER300CS \0\0 2048"},
{"OCEANVTX \0\0 2048"},
{"AQUAI750 \0\0 2048"},
};
static const oceanic_common_version_t aqualung_i450t_version[] = {
@ -594,7 +597,7 @@ oceanic_atom2_device_open2 (dc_device_t **out, dc_context_t *context, const char
// Get the correct baudrate.
unsigned int baudrate = 38400;
if (model == VTX) {
if (model == VTX || model == I750TC) {
baudrate = 115200;
}

View File

@ -43,7 +43,7 @@
#define DATAMASK 0x4347
#define COMPUMASK 0x4348
#define OC1A 0x434E
#define F10 0x434D
#define F10A 0x434D
#define WISDOM2 0x4350
#define INSIGHT2 0x4353
#define ELEMENT2 0x4357
@ -77,11 +77,13 @@
#define OCI 0x454B
#define A300CS 0x454C
#define MUNDIAL3 0x4550
#define F10B 0x4553
#define F11B 0x4554
#define XPAIR 0x4555
#define VISION 0x4556
#define VTX 0x4557
#define I300 0x4559
#define I750TC 0x455A
#define I450T 0x4641
#define I550T 0x4642
@ -163,13 +165,15 @@ oceanic_atom2_parser_create (dc_parser_t **out, dc_context_t *context, unsigned
parser->headersize += 2 * PAGESIZE;
} else if (model == ATOM1) {
parser->headersize -= 2 * PAGESIZE;
} else if (model == F10 || model == MUNDIAL2 || model == MUNDIAL3) {
} else if (model == F10A || model == F10B ||
model == MUNDIAL2 || model == MUNDIAL3) {
parser->headersize = 3 * PAGESIZE;
parser->footersize = 0;
} else if (model == F11A || model == F11B) {
parser->headersize = 5 * PAGESIZE;
parser->footersize = 0;
} else if (model == A300CS || model == VTX || model == I450T) {
} else if (model == A300CS || model == VTX ||
model == I450T || model == I750TC) {
parser->headersize = 5 * PAGESIZE;
}
@ -220,9 +224,9 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
oceanic_atom2_parser_t *parser = (oceanic_atom2_parser_t *) abstract;
unsigned int header = 8;
if (parser->model == F10 || parser->model == F11A ||
parser->model == F11B || parser->model == MUNDIAL2 ||
parser->model == MUNDIAL3)
if (parser->model == F10A || parser->model == F10B ||
parser->model == F11A || parser->model == F11B ||
parser->model == MUNDIAL2 || parser->model == MUNDIAL3)
header = 32;
if (abstract->size < header)
@ -282,7 +286,8 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
datetime->hour = bcd2dec (p[1] & 0x1F);
datetime->minute = bcd2dec (p[0]);
break;
case F10:
case F10A:
case F10B:
case F11A:
case F11B:
case MUNDIAL2:
@ -304,6 +309,7 @@ oceanic_atom2_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetim
case A300CS:
case VTX:
case I450T:
case I750TC:
datetime->year = (p[10]) + 2000;
datetime->month = (p[8]);
datetime->day = (p[9]);
@ -389,9 +395,9 @@ oceanic_atom2_parser_cache (oceanic_atom2_parser_t *parser)
// Get the dive mode.
unsigned int mode = NORMAL;
if (parser->model == F10 || parser->model == F11A ||
parser->model == F11B || parser->model == MUNDIAL2 ||
parser->model == MUNDIAL3) {
if (parser->model == F10A || parser->model == F10B ||
parser->model == F11A || parser->model == F11B ||
parser->model == MUNDIAL2 || parser->model == MUNDIAL3) {
mode = FREEDIVE;
} else if (parser->model == T3B || parser->model == VT3 ||
parser->model == DG03) {
@ -421,7 +427,8 @@ oceanic_atom2_parser_cache (oceanic_atom2_parser_t *parser)
o2_offset = 0x3E;
he_offset = 0x48;
ngasmixes = 6;
} else if (parser->model == A300CS || parser->model == VTX) {
} else if (parser->model == A300CS || parser->model == VTX ||
parser->model == I750TC) {
o2_offset = 0x2A;
if (data[0x39] & 0x04) {
ngasmixes = 1;
@ -499,17 +506,17 @@ oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns
if (value) {
switch (type) {
case DC_FIELD_DIVETIME:
if (parser->model == F10 || parser->model == F11A ||
parser->model == F11B || parser->model == MUNDIAL2 ||
parser->model == MUNDIAL3)
if (parser->model == F10A || parser->model == F10B ||
parser->model == F11A || parser->model == F11B ||
parser->model == MUNDIAL2 || parser->model == MUNDIAL3)
*((unsigned int *) value) = bcd2dec (data[2]) + bcd2dec (data[3]) * 60;
else
*((unsigned int *) value) = parser->divetime;
break;
case DC_FIELD_MAXDEPTH:
if (parser->model == F10 || parser->model == F11A ||
parser->model == F11B || parser->model == MUNDIAL2 ||
parser->model == MUNDIAL3)
if (parser->model == F10A || parser->model == F10B ||
parser->model == F11A || parser->model == F11B ||
parser->model == MUNDIAL2 || parser->model == MUNDIAL3)
*((double *) value) = array_uint16_le (data + 4) / 16.0 * FEET;
else
*((double *) value) = (array_uint16_le (data + parser->footer + 4) & 0x0FFF) / 16.0 * FEET;
@ -523,7 +530,8 @@ oceanic_atom2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, uns
gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium;
break;
case DC_FIELD_SALINITY:
if (parser->model == A300CS || parser->model == VTX) {
if (parser->model == A300CS || parser->model == VTX ||
parser->model == I750TC) {
if (data[0x18] & 0x80) {
water->type = DC_WATER_FRESH;
} else {
@ -589,7 +597,7 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
if (parser->mode != FREEDIVE) {
unsigned int idx = 0x17;
if (parser->model == A300CS || parser->model == VTX ||
parser->model == I450T)
parser->model == I450T || parser->model == I750TC)
idx = 0x1f;
switch (data[idx] & 0x03) {
case 0:
@ -633,9 +641,9 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
unsigned int samplesize = PAGESIZE / 2;
if (parser->mode == FREEDIVE) {
if (parser->model == F10 || parser->model == F11A ||
parser->model == F11B || parser->model == MUNDIAL2 ||
parser->model == MUNDIAL3) {
if (parser->model == F10A || parser->model == F10B ||
parser->model == F11A || parser->model == F11B ||
parser->model == MUNDIAL2 || parser->model == MUNDIAL3) {
samplesize = 2;
} else {
samplesize = 4;
@ -643,7 +651,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
} else if (parser->model == OC1A || parser->model == OC1B ||
parser->model == OC1C || parser->model == OCI ||
parser->model == TX1 || parser->model == A300CS ||
parser->model == VTX || parser->model == I450T) {
parser->model == VTX || parser->model == I450T ||
parser->model == I750TC) {
samplesize = PAGESIZE;
}
@ -670,7 +679,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
unsigned int pressure = 0;
if (have_pressure) {
unsigned int idx = 2;
if (parser->model == A300CS || parser->model == VTX)
if (parser->model == A300CS || parser->model == VTX ||
parser->model == I750TC)
idx = 16;
pressure = array_uint16_le(data + parser->header + idx);
if (pressure == 10000)
@ -728,7 +738,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
// Tank pressure (1 psi) and number
tank = 0;
pressure = (((data[offset + 7] << 8) + data[offset + 6]) & 0x0FFF);
} else if (parser->model == A300CS || parser->model == VTX) {
} else if (parser->model == A300CS || parser->model == VTX ||
parser->model == I750TC) {
// Tank pressure (1 psi) and number (one based index)
tank = (data[offset + 1] & 0x03) - 1;
pressure = ((data[offset + 7] << 8) + data[offset + 6]) & 0x0FFF;
@ -778,7 +789,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
parser->model == A300AI || parser->model == VISION ||
parser->model == XPAIR) {
temperature = ((data[offset + 7] & 0xF0) >> 4) | ((data[offset + 7] & 0x0C) << 2) | ((data[offset + 5] & 0x0C) << 4);
} else if (parser->model == A300CS || parser->model == VTX) {
} else if (parser->model == A300CS || parser->model == VTX ||
parser->model == I750TC) {
temperature = data[offset + 11];
} else {
unsigned int sign;
@ -817,7 +829,8 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
parser->model == AMPHOSAIR || parser->model == I550T ||
parser->model == VISION || parser->model == XPAIR)
pressure = (((data[offset + 0] & 0x03) << 8) + data[offset + 1]) * 5;
else if (parser->model == TX1 || parser->model == A300CS || parser->model == VTX)
else if (parser->model == TX1 || parser->model == A300CS ||
parser->model == VTX || parser->model == I750TC)
pressure = array_uint16_le (data + offset + 4);
else
pressure -= data[offset + 1];
@ -857,22 +870,14 @@ oceanic_atom2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_
}
sample.gasmix = gasmix - 1;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int o2 = parser->oxygen[gasmix - 1];
unsigned int he = parser->helium[gasmix - 1];
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix_previous = gasmix;
}
// NDL / Deco
unsigned int have_deco = 0;
unsigned int decostop = 0, decotime = 0;
if (parser->model == A300CS || parser->model == VTX || parser->model == I450T) {
if (parser->model == A300CS || parser->model == VTX ||
parser->model == I450T || parser->model == I750TC) {
decostop = (data[offset + 15] & 0x70) >> 4;
decotime = array_uint16_le(data + offset + 6) & 0x03FF;
have_deco = 1;

View File

@ -71,6 +71,7 @@ static const oceanic_common_version_t oceanic_veo250_version[] = {
{"VEO 180 R\0\0 256K"},
{"AERISXR2 \0\0 256K"},
{"INSIGHT R\0\0 256K"},
{"HO DGO2 R\0\0 256K"},
};
static const oceanic_common_layout_t oceanic_veo250_layout = {

View File

@ -123,7 +123,7 @@ dc_parser_new_internal (dc_parser_t **out, dc_context_t *context, dc_family_t fa
rc = cressi_edy_parser_create (&parser, context, model);
break;
case DC_FAMILY_CRESSI_LEONARDO:
rc = cressi_leonardo_parser_create (&parser, context);
rc = cressi_leonardo_parser_create2 (&parser, context, model);
break;
case DC_FAMILY_ATOMICS_COBALT:
rc = atomics_cobalt_parser_create (&parser, context);

View File

@ -527,13 +527,6 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
o2_previous = o2;
he_previous = he;
}

View File

@ -543,14 +543,6 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
}
sample.gasmix = parser->gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int he = parser->helium[parser->gasmix];
unsigned int o2 = parser->oxygen[parser->gasmix];
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
}
// Events
@ -733,12 +725,6 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
}
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE;
sample.event.time = seconds;
sample.event.value = o2;
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset += 2;
break;
case 0x06: // Gas Change
@ -765,12 +751,6 @@ suunto_d9_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t ca
}
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = seconds;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
offset += length;
break;
default:

View File

@ -275,6 +275,10 @@ suunto_eon_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Initial gas mix.
sample.gasmix = 0;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
unsigned int depth = 0;
unsigned int time = 0;
unsigned int interval = data[3];

View File

@ -608,17 +608,6 @@ static void sample_gas_switch_event(struct sample_data *info, unsigned short idx
sample.gasmix = idx - 1;
if (info->callback) info->callback(DC_SAMPLE_GASMIX, sample, info->userdata);
#ifdef ENABLE_DEPRECATED
unsigned int o2 = 100 * eon->cache.gasmix[idx-1].oxygen;
unsigned int he = 100 * eon->cache.gasmix[idx-1].helium;
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = idx;
sample.event.value = o2 | (he << 16);
if (info->callback) info->callback(DC_SAMPLE_EVENT, sample, info->userdata);
#endif
}
/*

View File

@ -170,6 +170,8 @@ suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
return DC_STATUS_DATAFORMAT;
unsigned int time = 0, depth = 0;
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int gasmix = 0;
unsigned int offset = 3;
while (offset < size && data[offset] != 0x80) {
@ -193,6 +195,13 @@ suunto_solution_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callbac
}
sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Gas change.
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix;
}
} else {
// Event.
sample.event.type = SAMPLE_EVENT_NONE;

View File

@ -319,6 +319,8 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
if (rc != DC_STATUS_SUCCESS)
return rc;
unsigned int gauge = data[4] & 0x40;
// Time
sample.time = 0;
if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
@ -327,6 +329,12 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.depth = 0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Initial gas mix
if (!gauge) {
sample.gasmix = 0;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
}
unsigned int depth = 0;
unsigned int time = 0;
unsigned int interval = data[3];
@ -394,12 +402,7 @@ suunto_vyper_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
sample.event.type = SAMPLE_EVENT_GASCHANGE;
sample.event.value = o2;
#else
sample.event.type = SAMPLE_EVENT_NONE;
#endif
break;
default: // Unknown
WARNING (abstract->context, "Unknown event");

View File

@ -216,6 +216,9 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
unsigned int time = 20;
unsigned int gasmix_previous = 0xFFFFFFFF;
unsigned int gasmix = 0;
unsigned int offset = header + 18;
while (offset + 2 <= size) {
dc_sample_value_t sample = {0};
@ -233,6 +236,13 @@ uwatec_memomouse_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.depth = depth * 10.0 / 64.0;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Gas change.
if (gasmix != gasmix_previous) {
sample.gasmix = gasmix;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix;
}
// Warnings
for (unsigned int i = 0; i < 6; ++i) {
if (warnings & (1 << i)) {

View File

@ -1153,15 +1153,6 @@ uwatec_smart_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
}
sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
#ifdef ENABLE_DEPRECATED
unsigned int o2 = parser->gasmix[idx].oxygen;
unsigned int he = parser->gasmix[idx].helium;
sample.event.type = SAMPLE_EVENT_GASCHANGE2;
sample.event.time = 0;
sample.event.flags = 0;
sample.event.value = o2 | (he << 16);
if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
#endif
gasmix_previous = gasmix;
}