15 Commits

Author SHA1 Message Date
Jef Driesen
7e3bf7eeb8 Use helper functions to decode multibyte values
Add and use some helper functions for decoding multibyte BCD and binary
encoded values, to remove some code duplication.
2022-05-23 12:00:35 +02:00
Jef Driesen
c6640aa7d3 Read the extra tank information
The latest firmware does store some additional information for each
tank. Right now it's not really used for anything yet, but it's
available for future use.
2022-02-27 11:49:53 +01:00
Jef Driesen
ed21d776dd Fix undefined behaviour in left shifts
Due to the integer promotion rules of the C language, the unsigned char
values are promoted to a signed integer (and not an unsigned integer)
before being shifted. But the result of a left shift on a signed type is
undefined if the resulting value can't be represented in the signed
type.

GCC's Undefined Behavior Sanitizer (ubsan), enabled with the option
-fsanitize=undefined, detects this type of problem at runtime with the
following warning: "left shift of X by Y places cannot be represented in
type 'int'".

Fixed with an explicit cast to unsigned integer.
2018-12-05 10:21:09 +01:00
John Van Ostrand
216e393f43 Add support for Pre-21000 s/n Commander dive computers
This adds support for older Cochran Commander dive computers,
specifically Commanders with serial numbers prior to 21000.

This also renames "Commander" model to "Commander II" and
adds "Commander I" to refer to pre-21000 models.
2017-07-05 13:11:33 +02:00
Jef Driesen
d40cdb4755 Add the devinfo event.
The devinfo event with the device serial number is required for the
fingerprint feature. Without this event, applications won't be able to
load (or save) the correct fingerprint. All necessary information is
already available in the initial handshake packet.
2016-04-26 10:59:02 +02:00
Jef Driesen
311bc85645 Add support for the Tusa IQ-700.
The Tusa IQ-700 is very similar to the other Seiko based models. The
most important change is that due the smaller amount of memory (8K vs
32K), the logbook entries are only 1 byte large instead of two bytes.
2015-04-22 08:25:03 +02:00
Anton Lundin
08dda98c29 Add utility functions to convert uints to bytes
Reviewed-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2014-12-21 15:00:02 +01: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
1e4d051b1e Move the bin/hex conversion functions to a common file. 2013-02-04 16:51:30 +01:00
Jef Driesen
97652c6c62 Make the bcd2dec() function available to all backends. 2009-12-08 14:51:32 +00:00
Jef Driesen
421f4ed1d6 Add functions to search for markers in an array. 2009-12-03 12:43:19 +00:00
Jef Driesen
043be07af4 Improve the detection of an empty logbook ringbuffer.
Some devices do not appear to set the ringbuffer pointers to their
normal empty values (e.g. pointing outside the ringbuffer memory). In
that case, there appears to be a single entry. But since that entry
contains uninitialized memory (e.g. all 0xFF bytes), we are able to
detect this special situation.
2009-06-19 08:43:42 +00:00
Jef Driesen
99c3d258d4 Added byte order conversion functions (little and big endian). 2009-03-11 10:18:05 +00:00
Jef Driesen
596af5a17b Add LGPL license headers. 2008-10-05 20:14:18 +00:00
Jef Driesen
5e8d18944a Moved all array reversal functions to a common file. 2008-07-30 09:03:37 +00:00