28 Commits

Author SHA1 Message Date
Jef Driesen
156f54302d Add basic timezone support
Allthough most dive computers always use local time and don't support
timezones at all, there are a few exceptions. There are two different
sources of timezone information:

 - Some of the newer Uwatec/Scubapro devices use UTC internally and also
   support a timezone setting. This UTC offset is currently taken into
   account to obtain the dive date/time, but the UTC offset itself is
   lost.

 - Uwatec/Scubapro and Reefnet devices rely on the clock of the host
   system to synchronize the internal device clock and calculate the
   dive date/time. The consequence is that the resulting date/time is
   always in the timezone of the host system.

In order to preserve this timezone information, the dc_datetime_t
structure is extended with a new "timezone" field, containing the UTC
offset in seconds. Devices without timezone support will set the field
to the special value DC_TIMEZONE_NONE.

The dc_datetime_localtime() and dc_datetime_gmtime() functions will
automatically populate the new field with respectively the local
timezone offset and zero. The dc_datetime_mktime() function will take
into account the new timezone field for the conversion to UTC. The
special value DC_TIMEZONE_NONE is interpreted as zero.
2017-08-18 23:26:45 +02:00
Jef Driesen
d1a06e784c Remove deprecated functions from the public api
The vendor_product_parser_create() and vendor_product_device_open()
functions should be called indirectly, through the generic
dc_device_open() and dc_parser_new() functions. And the
vendor_product_extract_dives() functions are internal functions that
should never have been part of the public api in the first place.
2017-04-18 08:41:10 +02:00
Jef Driesen
390b5fe553 Report the initial gas mix on the first sample
For dives with multiple gas mixes, an application doesn't have enough
info to figure out which one is the initial gas mix. Usually it's the
first gas mix, but that's not guaranteed. Reporting the intial gas mix
on the first sample avoids this problem.
2016-11-04 19:26:21 +01:00
Jef Driesen
ff29d218bb Use helper functions to allocate and free objects.
Both the allocation and initialization of the object data structure is
now moved to a single function. The corresponding deallocation function
is intended to free objects that have been allocated, but are not fully
initialized yet. The public cleanup function shouldn't be used in such
case, because it may try to release resources that haven't been
initialized yet.
2016-01-05 20:40:21 +01:00
Jef Driesen
9bc14dca10 Remove some boilerplate code from the cleanup functions.
Instead of freeing the object data structure in the backend specific
cleanup function, the memory is now freed automatically in the base
class function. This reduces the amount of boilerplate code in the
backends. Backends that don't allocate any additional resources, do no
longer require a cleanup function at all.
2016-01-05 20:40:21 +01:00
Jef Driesen
106abe2dba Remove the temperature and pressure samples.
With the new temperature and pressure field, artificially injecting the
temperature and pressure info from the header into the samples is no
longer necessary. Applications will typically expect a real temperature
or pressure profile, and not a few discrete points.

The two surface samples (with zero depth) at the begin and end of the
dive are kept for now, to support events that occur at the surface.
2015-05-08 08:17:18 +02:00
Jef Driesen
7278a70afe Implement the tank and temperature fields. 2015-05-08 08:15:09 +02:00
Jef Driesen
e1f939c131 Move all caching code to a common function. 2015-05-05 21:15:51 +02:00
Jef Driesen
23acddbe08 Eliminate ghost events caused by unknown events.
The newest Suunto models (e.g. D4i, D6i, D9tx and DX) support a few
additional events (type 0x15 and higher), which are not supported yet
because their interpretation isn't known.

Due to a nasty bug, these unkown events result in "ghost" events. When
such an unknown event is encountered, the sample type field isn't set
explicitely. Therefore it simply retains the value from the previous
sample, whatever that might be. If the previous sample happens to be an
event as well, then the unknown event will show up as a duplicate event.
But if the previous sample is not an event, then the resulting event
type is undefined.

This is fixed by always resetting the event type explicitely. Those
unknown events are also suppressed now and no longer delivered to the
application.

Allthough I haven't observed this bug with the Suunto Eon and Vyper,
they could be affected too.
2015-05-04 15:50:53 +02:00
Florian Klink
fc008312b5 Remove trailing whitespaces
Most of them appear in the disclaimers, but some are in the code as
well.
2014-03-19 09:16:07 +01:00
Jef Driesen
6419e189a4 Add a single isinstance function per object type.
Currently, each backend has it's own function to verify whether the
object vtable pointer is the expected one. All these functions can be
removed in favor of a single isintance function in the base class,
which takes the expected vtable pointer as a parameter.

Functions which are called through the vtable, don't need to verify the
vtable pointer, and those checks are removed.
2013-04-16 12:18:54 +02:00
Jef Driesen
007479fc92 Rename the backend structure to vtable.
The term "backend" can be confusing because it can refer to both the
virtual function table and the device/parser backends. The use of the
term "vtable" avoids this.
2013-04-16 12:18:53 +02:00
Jef Driesen
cd31ff9dff Properly store the context pointer internally.
I forgot to update the device and parser initialization functions to
store the context pointer into the objects. As a result, the internal
context pointers were always NULL.
2012-08-28 08:44:47 +02:00
Jef Driesen
53e9d72a40 Integrate the context object in the library.
The public api is changed to require a context object for all
operations. Because other library objects store the context pointer
internally, only the constructor functions need an explicit context
object as a parameter.
2012-08-27 23:08:38 +02:00
Jef Driesen
c821d40144 Introduce a namespace prefix for the high-level public api.
Adding the "dc_" namespace prefix (which is of course an abbreviation
for libdivecomputer) should avoid conflicts with other libraries. For
the time being, only the high-level device and parser layers are
changed.
2012-06-21 21:42:37 +02:00
Jef Driesen
163d383332 Use a common backend type for the device and parser layers. 2012-06-21 21:42:37 +02:00
Jef Driesen
9136a52835 Use common status codes for the device and parser layers. 2012-06-21 21:42:34 +02:00
Jef Driesen
e65025b501 Separate private and public headers.
The public header files are moved to a new subdirectory, to separate
the definition of the public interface from the actual implementation.
Using an identical directory layout as the final installation has the
advantage that the example code can be build outside the project tree
without any modifications to the #include statements.
2012-06-21 21:39:24 +02:00
Jef Driesen
014f7aa420 Implement the new field api for the Suunto devices. 2011-01-13 22:14:53 +01:00
Jef Driesen
90e60fecee Add a new function to the public api to retrieve the dive metadata. 2011-01-13 22:14:53 +01:00
Jef Driesen
154f767a9c Convert assertions into error codes. 2011-01-08 23:40:15 +01:00
Jef Driesen
8dd1647ede The Solution Nitrox/Vario stores nitrox data, not tank pressure. 2010-05-27 00:15:59 +02:00
Jef Driesen
f569f402f2 Fix the decoding of negative temperatures. 2010-05-22 22:19:34 +02:00
Jef Driesen
d7c2fbbf18 Introduce surface samples for the pressure and temperature data.
The Suunto Vyper, Spyder and Eon store a surface event after the last
depth sample. Adding an artificial zero depth sample avoids the problem
of having an incomplete sample without a depth measurement.

Because these devices also store the tank pressure and/or the
temperature at the begin/end of the dive, these measurements are
associated with the new surface samples.
2010-05-22 22:11:52 +02:00
Jef Driesen
fd9390e8a8 Associate the events with the correct sample timestamp. 2010-05-21 23:12:24 +02:00
Jef Driesen
de889f9d46 Return the right type of error code. 2010-02-11 08:26:35 +00:00
Jef Driesen
a8116a0aec Add datetime support to the parsers. 2010-02-02 15:04:46 +00:00
Jef Driesen
098b229bc6 Rename the Suunto Spyder parser as the Eon parser.
Both devices have an almost identical data format. Renaming the parser
backend makes it more consistent with the corresponding device backend.
2010-02-01 13:34:52 +00:00