657 Commits

Author SHA1 Message Date
Jef Driesen
99fe2c693f Support both the OC and CC gas mixes.
The Shearwater Predator has two different sets of gas mixes for OC
(Open Circuit) and CC (Closed Circuit) mode. Since the dive mode can
be switched during the dive (e.g. in a bailout scenario), there is no
easy way to select one of both sets. With this change, both sets are
returned. It's not a perfect solution, but for CC dives it's already
an improvement.
2012-12-06 20:01:46 +01:00
Jef Driesen
500fb1e16b Add support for the Shearwater Predator. 2012-12-05 16:08:47 +01:00
Jef Driesen
e7d5afb1e4 Remove the version function for the Uwatec Smart.
The Uwatec Smart protocol supports reading individual settings. However
the version functions only reads those three values that we use
internally (model, serial number and device clock). That's a very
arbitrary subset and it would be much better to support reading
specific values. But that's something for later...
2012-12-05 16:07:32 +01:00
Jef Driesen
985323eefb Move the version function to the device specific api.
The version function requires device specific knowledge to use it (at
least the required buffer size), it is already called internally when
necessary, and only a few backends support it. Thus there is no good
reason to keep it in the high-level public api.
2012-12-05 16:07:32 +01:00
Jef Driesen
2a9e8c0023 Add some missing size macros.
These size macros are required to use the device specific functions
correctly and should therfore be exposed in the public api.
2012-12-05 16:07:32 +01:00
Jef Driesen
550e37d0b5 Remove the page, packet and memory size macros from the public api.
These macros are used internally and don't need to be exposed. In some
cases, the actual values are not even constant, but dependant on the
model and/or the firmware version.
2012-12-05 16:07:32 +01:00
Jef Driesen
43a518b1d2 Autodetect the three OSTC variants.
The exact OSTC variant can be detected by means of the serial number.
Each of the three variants is now assigned an artifical model number,
and included explicitly in the list of supported models.
2012-12-01 16:48:37 +01:00
Jef Driesen
3502ad39a6 Check the salinity byte for out of range values.
Apparently some older firmware versions don't support the salinity
setting. Because unused bytes are initialized with zero, the salinity
value will be reported as being zero.

To fix this unexpected value, the salinity factor is first checked for
valid values. If the value is out of range, a DC_STATUS_UNSUPPORTED
error is returned to indicate the absence of the value.
2012-12-01 16:48:14 +01:00
Jef Driesen
d3de4bf9bd Update the example application for the new fields.
Update the example application to support the new salinity and
atmosperic pressure fields. Because the new fields are not supported by
all backends, they are only included in the output when available.
2012-12-01 14:20:12 +01:00
Jef Driesen
e4b66048a6 Add some documentation for the event values.
For the new packed 16bit event values, some minimal documentation is
required to interpret the value correctly.
2012-11-24 11:44:08 +01:00
Dirk Hohndel
1d360d3a1e This adds support for a subset of the events the OSTC provides.
- PO2 warnings (high and low both mapped to the same SAMPLE_EVENT_PO2
  event)
- SPEED warning (which according to hw isn't emitted at this point)
- Deco stop violations (both deep and regular mapped to same
  SAMPLE_EVENT_CEILING event)
- Deco ceiling and time (this is reported as a series of
  SAMPLE_EVENT_DECOSTOP events with packed deco stop depth (in m) and
  time (in seconds)
  A SAMPLE_EVENT_NDL event (with an optional value indicating the non-stop
  time remaining) indicates that the ceiling has been resolved
- Gas change (reported as SAMPLE_EVENT_GASCHANGE2, using another
  unfortunate O2% / He% semantic that is used in the
  SAMPLE_EVENT_GASCHANGE
  This also covers the manual gas set event of the OSTC
- Manual Marker (reported as SAMPLE_EVENT_BOOKMARK)

The two new events (SAMPLE_EVENT_GASCHANGE2 and SAMPLE_EVENT_NDL are added
to the universal app as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-24 11:43:59 +01:00
Dirk Hohndel
360a318334 Add support for salinity and atmospheric pressure
This adds a new type dc_salinity_t and associated enum dc_water_t.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-24 11:41:58 +01:00
Jef Driesen
909679a48c Post release version bump to 0.3.0. 2012-09-21 22:47:22 +02:00
Jef Driesen
2ed54a204b Release version 0.2.0. v0.2.0 2012-09-21 22:46:30 +02:00
Jef Driesen
2511ebea3f Use the ifset macro to append the version suffix.
The version suffix is always defined. The correct condition for
appending the version suffix is whether it's defined as the empty
string or not.
2012-09-21 22:37:01 +02:00
Jef Driesen
743e434e5d Include the msvc project file in the tarballs. 2012-09-21 21:59:08 +02:00
Jef Driesen
af51b58a09 Use non-standard replacement functions for msvc. 2012-09-21 21:59:08 +02:00
Jef Driesen
14b28cb993 Add explicit casts for the msvc C++ compiler. 2012-09-21 21:59:08 +02:00
Jef Driesen
8b4d216131 Update the msvc project file. 2012-09-21 21:59:08 +02:00
Jef Driesen
aaff9c7500 Update the list with supported models. 2012-09-21 21:26:20 +02:00
Jef Driesen
2f8ec75c7c Merge branch 'release-0.1'
Integrate the bugfixes from the stable branch.
2012-09-21 21:24:04 +02:00
Jef Driesen
4df5e49008 Take the gas model into account to parse the gas mixes.
When the gas model setting is set to air, the individual gas mix
definitions retain their previous (non-air) values. This is convenient
to avoid having to adjust the gas mixes again on your next nitrox or
mixed gas dive. But the consequence is that for air dives, the gas model
should take precedence over the individual gas mix definitions, and a
single mix with air is returned instead.
2012-09-21 20:52:02 +02:00
Jef Driesen
136f1d1fe1 Fix the gas mix parsing.
The Suunto D9tx stores the gas mix definitions at a different offset
compared to the D4i and D6i.
2012-09-21 20:48:44 +02:00
Jef Driesen
2487167778 Don't exceed the maximum number of bytes.
We received data from a device where the end-of-profile marker is
missing. Because the device fails to locate the last dive, it goes into
an infinite loop, and keeps sending the same sequence of dives over and
over again. As a result, we receive more data than expected, and the
assert in the progress event is triggered.

We now keep track of the maximum number of bytes remaining and abort
once the limit is passed. The values of the progress events are capped
at the maximum value to avoid the assertion.
2012-09-20 23:17:17 +02:00
Jef Driesen
ddf6fca65f Add support for the Uwatec Galileo Trimix. 2012-09-20 20:40:38 +02:00
Sascha Kettler
074bee70a2 Fixed date parsing for Oceanic VEO 3.0 2012-09-17 22:04:30 +02:00
Jef Driesen
ae763c3f58 Verify the header in the logbook and profile are identical.
Unless we have a bug in the logbook processing logic, both logbook
headers should always be identical. But it doesn't hurt to check
explicitly.
2012-09-17 21:26:06 +02:00
Jef Driesen
9366e36309 Finish immediately if there are no dives available.
When trying to continue when no dives are available, malloc() will be
called to allocate zero bytes. The result is implementation defined and
may return a NULL pointer. Since that would be interpreted as an error,
it's safer to finish immediately.
2012-09-17 20:44:34 +02:00
Jef Driesen
f4eeb7745e Return a negative value to indicate truncation.
If the maximum availalbe buffer size is zero, no data can be written
(not even the NULL terminator), and a negative values should be returned
to indicate truncation.
2012-09-15 13:54:48 +02:00
Jef Driesen
dad451f6f9 Add a command line option to increase the loglevel.
By default, the universal application will always log error and warning
messages, but the loglevel can be increased to also log info and debug
messages.
2012-09-15 13:54:48 +02:00
Jef Driesen
55c16d0d0f Adjust the default logformat.
The file, line and function information is now only printed for error
and debug messages.
2012-09-15 13:54:48 +02:00
Jef Driesen
ea3f833d8d Add additional messages for diagnostic purposes. 2012-09-15 13:54:48 +02:00
Jef Driesen
645bd89d8a Add a convenience function for logging hexdumps.
The main logging function isn't really suitable for generating inline
hexdumps directly from the binary data. There is simply no format string
available for converting array data types with just a single printf
call.

A possible solution would be to require the caller to perform the string
conversion before calling the standard logging function. But that's not
acceptable, because it doesn't play well with the ability to disable the
logging at compile time, requires extra memory and clutters the calling
code unneccessary.

The new function is a compromise which sacrifices flexibility for
simplicity, by using a hardcoded output format with a custom prefix.
It's not a perfect solution, but it works well enough for the intended
purpose.
2012-09-15 13:52:49 +02:00
Jef Driesen
1b7eaaa831 Add support for the Oceanic OCS. 2012-09-11 20:26:20 +02:00
Jef Driesen
fab606b00a Add an option to enable support for pseudo terminals.
Pseudo terminals are very convenient for testing purposes, but they are
not fully compatible with real serial (or even usb-serial) hardware.
With the new option, some workarounds can be enabled to hide the
differences and increase compatibility. Although these workarounds
shouldn't cause any problems in production builds, the advise is to
disable this feature.

A few ioctl's are not supported for pseudo terminals. They fail with
EINVAL (Linux) or ENOTTY (Mac OS X). Since these specific error codes
should not occur under normal conditions, they are simply ignored when
pseudo terminal support is enabled.

The TIOCEXCL ioctl (exclusive access) is also problematic. The TIOCEXCL
setting is shared between the master and slave side of the pty. When the
setting is applied on the slave side, it persists for as long as the
master side remains open. The result is that re-opening the slave side
will fail with EBUSY, unless the process has root priviliges. Since this
is very inconvenient, the TIOCEXCL setting is not used when pseudo
terminal support is enabled.
2012-08-28 23:30:43 +02:00
Jef Driesen
6cb4bc6a06 Enable exclusive access mode.
With exclusive access mode, no further open() operations on the terminal
are permitted, except for a process with root priviliges. Non-root
processes will fail with EBUSY. This change will prevent other processes
from accidentally messing up the communication. It also makes the
behaviour similar to Windows, where serial ports are always opened with
exclusive access.
2012-08-28 23:30:26 +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
4251f1e522 Update the dummy IrDA backend for Mac OS X.
I forgot to update the dummy IrDA backend with the latest changes. The
error, init and cleanup functions have been removed, and the
irda_socket_open function now takes a context pointer.
2012-08-28 08:36:44 +02:00
Jef Driesen
55b8dbf3be Fix a mistake introduced during the latest merge commit.
The status codes in the new EXITCODE macro were not updated to use the
new constants with the namespace prefix. As a result building fails when
compiling with libusb support.
2012-08-28 08:32:12 +02:00
Jef Driesen
853407ac52 Add a wrapper for the vsnprintf function.
The non-standard vsnprintf implementation provided by MSVC doesn't
matches the C99 function. The wrapper function provides a consistent
interface on top of the native functions.
2012-08-27 23:08:39 +02:00
Jef Driesen
aae856a310 Silence compiler warnings (unused variables).
When the logging is disabling, several compiler warnings regarding
unused variables appear. With the cast to void and sizeof trick the
warnings are silenced without causing any side effects.
2012-08-27 23:08:38 +02:00
Jef Driesen
b1b30f068c Add an option to disable the logging.
With the new option, the library can be compiled with the entire
logging infrastructure disabled. The public api remains unchanged, but
the internal logging functions will have no effect anymore.

In practice the overhead of the logging functions should be quite
small, and disabling the logging at runtime might be more convenient.
Especially because troubleshooting will become much harder without any
logging.
2012-08-27 23:08:38 +02:00
Jef Driesen
866e636e8c Move the logging code to the examples.
With the application defined logging function, the actual logging is not
performed by the library anymore, and the code belongs in the
applications.
2012-08-27 23:08:38 +02:00
Jef Driesen
30feb3b3ed Remove the obsolete error functions. 2012-08-27 23:08:38 +02:00
Jef Driesen
38c7b022cd Integrate the context object in the serial code. 2012-08-27 23:08:38 +02:00
Jef Driesen
ffad80316c Integrate the context object in the IrDA code. 2012-08-27 23:08:38 +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
3311960795 Add a convenience function for logging system errors.
The new convenience function provides a centralized and threadsafe
function for logging system errors. The previous functions are
deprecated and will be removed after the transition to the new context
based logging.
2012-08-27 23:02:44 +02:00
Jef Driesen
43cd111198 Add support for an application defined logging function.
An application can now register an application defined callback
function, which will perform the actual logging. This provides
additional flexibility compared to logging to stderr with a hardcoded
format. Applications can now easily display the messages in their user
interface, customize the format, etc.

Although the internal logging function is a printf like function, the
arguments are converted into a plain string before being passed to the
callback function. This greatly improves interoperability with
programming languages which don't support C style variadic functions
(e.g. Python, C#, etc).
2012-08-27 23:02:44 +02:00
Jef Driesen
0f6d23757f Add a new library context object.
With the introduction of a context object, library initialization and
shutdown can be performed without requiring any global state. A single
process can use multiple independent contexts without any problems. The
lack of a global state also improves the thread-safety of the library.

At the moment, the new context object is primary used to implement an
improved logging system.
2012-08-27 23:02:44 +02:00