1142 Commits

Author SHA1 Message Date
Jef Driesen
ce472ffa19 Add the read and write commands. 2016-01-05 20:38:47 +01:00
Jef Driesen
195c4c7a7e Add the download command. 2016-01-05 20:38:47 +01:00
Jef Driesen
bfbb56c781 Add the dump command. 2016-01-04 19:50:51 +01:00
Jef Driesen
ff7c3f6901 Add the list command. 2016-01-04 19:50:51 +01:00
Jef Driesen
4dee95d352 Add the version command. 2016-01-04 19:50:51 +01:00
Jef Driesen
38c9ebc74e Add the help command. 2016-01-04 19:50:51 +01:00
Jef Driesen
57a54f824c Add helper functions for converting hexadecimal data. 2016-01-04 19:50:51 +01:00
Jef Driesen
8f61648a39 Add helper functions for reading/writing binary files. 2016-01-04 19:50:51 +01:00
Jef Driesen
5188f5c25f Add a helper function for translating status codes. 2016-01-04 19:50:51 +01:00
Jef Driesen
655e9ad312 Add a default event handler. 2016-01-04 19:50:51 +01:00
Jef Driesen
28d8759294 Setup the cancel signal handler. 2016-01-04 19:50:51 +01:00
Jef Driesen
f0e5edc50b Setup the device descriptor. 2016-01-04 19:50:51 +01:00
Jef Driesen
3c57060d95 Setup the library context. 2016-01-04 19:50:51 +01:00
Jef Driesen
689e1f1f55 Change the format for error and warning messages.
Use the same format as used for printing the error and warning messages
from libdivecomputer itself.
2016-01-04 19:50:51 +01:00
Jef Driesen
b5503e53fd Add a more modular example application.
The universal application works well, but is quite difficult to extend
with more functionality. Therefore a new and more modular application is
needed. The new dctool application will support multiple sub-commands,
to carry out specific actions. Extending the application will be as easy
as adding new commands.
2016-01-04 19:50:51 +01:00
Jef Driesen
dd779d531a Fix the date parsing for several models.
To store the day (range 1 to 31) as a binary encoded value, only 5 bits
are required. The extra 6th bit is part of the year. The year is also
not BCD encoded. This happened to work by accident, because for a single
nibble, the current implementation of the bcd2dec() function returns the
binary value.
2016-01-04 19:30:40 +01:00
Jef Driesen
06e0de6712 Add a new sample with the active gas mix.
The new gasmix sample contains the index of the active gas mix.

This new sample is intended as a replacement for the existing gas change
events (SAMPLE_EVENT_GASCHANGE and SAMPLE_EVENT_GASCHANGE2). To maintain
backwards compatibility, the legacy events are marked as deprecated but
not removed yet.
2015-12-21 14:03:39 +01:00
Jef Driesen
d839852953 Parse the profile to retrieve the bailout gas mixes.
In CC mode, only the diluents are stored in the header. The list with
the OC gas mixes, which are used for bailout, are not stored in the
header. In order to retrieve the bailout mixes too, we need to parse the
profile and add them to the manual gas mixes.
2015-12-21 12:58:02 +01:00
Jef Driesen
5c6c4cccc7 Add support for the DiveSystem iX3M series.
The protocol of the iX3M series is almost identical to the protocol of
the iDive series. The main difference is that the command bytes and the
size of the response packets have been changed. In order to be able to
communicate with the correct set of commands, the user needs to supply
the correct number now. To maintain backwards compatibility, a new
variant of the open function is added.
2015-12-14 12:23:31 +01:00
Jef Driesen
d516376ce7 Improve the support for pseudo terminals.
Apparantly Fedora applies a custom patch to glibc's tcsetattr()
function, which adds an extra check to verify the PARENB/CREAD/CSIZE
bits in the termios c_cflag field.

However, in commit 197b9f09421111e03588c94d55a72aa6ec624c63 we already
discovered that for pty's, some of the termios settings make no sense at
all, and therefore the Linux kernel always does:

    tty->termios.c_cflag &= ~(CSIZE | PARENB);
    tty->termios.c_cflag |= (CS8 | CREAD);

Thus, instead of ignoring such nonsense termios settings, the kernel
changes the termios structure to reflect what pty's actually do. The
consequence is that these settings will not stick, and cause the extra
check in the Fedora specific patch to fail.

To workaround this problem, we ignore the error when building
libdivecomputer with pty support enabled.
2015-12-10 19:41:41 +01:00
Gilbert J. M. Forkel
07c9cf8950 Correctly detect a device without any dives.
If the dive computer has not recorded any dives yet, the profile pointer
isn't valid and contains the default value 0xFFFFFFFF. There is no need
to return an error in this case.
2015-12-10 14:53:45 +01:00
Jef Driesen
a4838e7cfc Fix the layout for the Oceanic Atom 1.0.
The profile ringbuffer starts already at address 0x0440 instead of
0x0A40. The logbook ringbuffer is therefore a bit smaller too.
2015-12-06 17:40:41 +01:00
Jef Driesen
a155fb717b Add extra debug information to the error messages.
With the extra debug information it's easier to investigate the
underlying problem, without needing a debugger.
2015-12-06 17:40:02 +01:00
Jef Driesen
9ee3a10390 Add a workaround for a missing initial gas mix.
In some rare cases, the initial gas mix contains the value 0xFF. This
value is obviously outside the expected range (1-5), and therefore
causes the parsing to fail. It's not really clear how this can happen.

As a workaround for the fatal error, we now ignore the invalid value and
simply proceed without a gas mix.
2015-12-06 17:38:03 +01:00
Jef Driesen
842c4ca466 Fix the salt water conversion.
The dive computer records the raw absolute pressure. To convert this
pressure value into a depth, we need to divide by the salinity factor,
not multiply!
2015-11-10 10:42:36 +01:00
Jef Driesen
4552558e87 Use an output parameter for the number of bytes.
With the number of bytes returned separately from the error code, we can
immediately return the correct error code.
2015-11-10 08:24:15 +01:00
Jef Driesen
fb5f7ad971 Use the GCC printf format attribute.
This enables the compiler to check the arguments against a printf style
format string in all calls to the logging functions.
2015-11-06 07:52:27 +01:00
Jef Driesen
0a20eae342 Prefer the C99 identifier for the function name.
The GCC 5 compiler with -Wpedantic enabled generates warnings for the
non-standard predefined identifier __FUNCTION___. These warnings can be
avoided by using the C99 identifier __func__ instead.
2015-11-06 07:51:42 +01:00
Jef Driesen
84d67c5544 Add support for the new OSTC logbook format.
With the new logbook format version 0x24, the OSTC no longer stores the
date/time at the end of the dive, but at the start of the dive.
2015-10-29 09:50:37 +01:00
Jef Driesen
ae70d1efba Fix the dive mode for the Galileo Trimix.
Parsing the gas mixes has been implemented a while ago, so this check is
no longer neccessary.
2015-10-29 09:28:56 +01:00
Jef Driesen
8ac9778c9e Merge branch 'atom2' 2015-10-28 08:56:23 +01:00
Jef Driesen
aa2499ef0f Implement gas switches for the Hollis TX1. 2015-10-28 08:27:24 +01:00
Jef Driesen
99300d4e37 Implement ndl/deco support for the Hollis TX1. 2015-10-28 08:27:24 +01:00
Jef Driesen
3b0e36ccbf Implement ndl/deco support for the Tusa Zen. 2015-10-28 08:27:24 +01:00
Jef Driesen
7341403f73 Fix the temperature for the Tusa Zen. 2015-10-28 08:27:24 +01:00
Jef Driesen
95aa477129 Cache the parser data internally. 2015-10-28 08:27:24 +01:00
Jef Driesen
6f89e445e3 Convert the internal tank id to an index.
The internal Uwatec tank id should be converted to the libdivecomputer
tank index. If there is no corresponding tank, the tank pressure samples
are dropped for the following reasons:

Some models appear to record an absolute tank pressure sample, even if
there is no pressure sensor attached to the corresponding tank. In this
case only the tank index changes. The sample value simply retains the
last pressure of the previous tank. Since we don't have any real
pressure data, dropping those samples is fine.
2015-10-28 08:26:58 +01:00
Jef Driesen
a21f60e0bc Handle a libusb timeout as a non fatal error.
Dives are downloaded using bulk transfers with an 8K buffer. Normally
the 2 second timeout is more than sufficient, and the timeout should
never expire, unless there is some serious communcation problem. But
nevertheless, users are reporting timeouts for dives having a length
that is an exact multiple of the USB packet size (64 bytes). In that
case, libusb reports a timeout with an non-zero amount of bytes
received. Despite the timeout, the received data contains a complete
dive.

I suspect libusb is somehow unable to determine whether the transfer is
complete and therefore waits until the timeout expires. For transfers
that are not a multiple of the USB packet size, the end of the transfer
is indicated by the last incomplete packet. This is not the case if the
length is an exact multiple of the USB packet size. This problem is
usually solved by sending a zero-length packet. Maybe the USB stack of
the Cobalt is not sending such a zero-length packet?

Atomics will address the problem with a Coblat 2 firmware upgrade, that
will simply append two zero bytes if the length is a multiple of 64
bytes. As a workaround for older firmware versions, we ignore the
timeout and process all received data. This shouldn't have any
disadvantages. An incomplete dive, for example due to a real timeout,
will now be detected by means of the minimum length and/or the checksum.
2015-10-28 08:08:17 +01:00
Robert C. Helling
00e0cfa0ab Mention Shearwater Nerd alongside with Petrel 2
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2015-10-16 19:55:57 +02:00
Janice
0efa420b71 Convert ndl/deco time to seconds. 2015-10-14 09:11:47 +02:00
Giorgio Marzano
95bdea93cd Use the correct memory layout and packet size. 2015-10-05 15:11:34 +02:00
Giorgio Marzano
cb06adef35 Add support for the Mares Smart Apnea.
The Mares Smart Apnea uses a different data format than the regular
Smart, because it records not only a summary of each freedive in the
session, but also a full depth profile.

Because both the regular Smart and the Smart Apnea have the same model
number (0x10), another way to distinguish the two variants is needed.
Therefore, the Smart Apnea gets a modified model number, with one of the
higher bit set. The actual type is detected from the contents of the
version packet.

The new Smart Apnea is also capable of recording multiple samples per
second (e.g. 2, 4 or 8). But since our smallest unit of time is one
second, we can't represent this, and the extra samples will get dropped
for now.
2015-09-30 08:19:59 +02:00
Jef Driesen
3fa606a8a2 Fix the gas switches for Galileo Trimix.
The Galileo Trimix supports up to 10 tanks and gas mixes. However, the
existing alarm based gas switch events have only 2 bits available, and
can support at most 4 gas mixes. Therefore, the trimix variant stores
another 4 bit value in the second alarm byte.

For the first three gas mixes (and possibly also the fourth), both alarm
bytes appear to be always set to the same value. For the higher mixes,
the value in the first alarm byte is always zero. This doesn't cause any
problems, because in the data stream the second alarm byte is stored
after the first one, and our final value is always the last one.

The non-trimix variant also has the second alarm byte, but the gas mix
bits appear to be always zero. In order to avoid taking this zero as the
final value, a separate table is used for the trimix variant.
2015-09-17 11:24:16 +02:00
Jef Driesen
52453f080d Add support for the tank field.
The air integrated uwatec aladin models do record the total consumption,
and not the begin/end pressure. Returning the total consumption as the
begin pressure, combined with a zero end pressure is strictly speaking
not correct, but it still provides useful information.
2015-09-11 22:41:46 +02:00
Jef Driesen
ddbcdeecbb Ignore disconnected O2 sensors.
Even if there are no O2 sensors connected (for example in auto or fixed
setpoint mode), the device records a ppO2 sample with all three values
set to zero. Such samples are now ignored, as if there was no ppO2
sample present.

Reported-by: Anton Lundin <glance@acc.umu.se>
2015-09-10 09:25:06 +02:00
Jef Driesen
c72bdfe4e4 Add support for logging I/O operations.
The Atomics Cobalt backend uses libusb directly, without going through
an internal I/O layer that support logging. Therefore the logging needs
to be done in the backend itself.
2015-09-07 22:51:44 +02:00
Jef Driesen
55afe711f7 Fix the layout for the Oceanic Pro Plus 3.
The logbook ringbuffer starts at address 0x03E0 instead of 0x240. Since
none of the other models uses the same address, a completely new layout
structure is necessary.
2015-08-29 09:16:49 +02:00
Jef Driesen
3ff890b3e2 Improve the detection of unused tanks.
The begin/end pressure for unused tanks is normally zero. But I noticed
that in some cases both pressure values are stored as 0xFFFF. Since that
corresponds to a pressure of 511.99 bar, this is most likely some
special magic value, and not a valid pressure.

Tanks where either the begin or end pressure is 0xFFFF are now ignored
too.
2015-08-28 07:28:26 +02:00
Jef Driesen
5381714d08 Fix a bug in the tank id.
Due to a bitshift with the wrong number of bits, the tank id was always
zero for the Uwatec trimix firmware.
2015-08-20 09:08:56 +02:00
Jef Driesen
922d219bdc Add support for the tank field. 2015-08-10 13:10:44 +02:00