Dirk got a log from Amin that shows
Discovered new device: "EZ001945" "LE:{cb0ff33a-40d3-63eb-2764-11e63896534f}"
Not recognized as dive computer
and that's the i750TC device model name. It's not recognized as a dive
computer because subsurface don't have that EZ as a model version, but
even if it did, it would not try to use BLE to download because
libdivecomputer doesn't mark it as BLE capable.
But it appears that it is, so add the protocol marker (even if the log
Dirk has then shows a failure to connect, so not all is well).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Merge with Jef's upstream libdivecomputer updates:
- support new Ratio iX3M 2021 model IDs
- support Mares Horizon, and fix the Mares Genius layout
- add support for Shearwood Sage
- various warning fixes, other minor details
* 'master' of git://github.com/libdivecomputer/libdivecomputer: (23 commits)
Wait before sending the firmware data
Add support for the new iX3M 2021 models
Avoid generating the SIGPIPE signal
Use an unsigned value to represent the undefined state
Use an unsigned integer for the number of dives
Use the cross-platform socket file descriptor type
Limit the size to INT_MAX
Define DC_TIMEZONE_NONE as a signed integer
Use an unsigned integer for the length
Fix -Wsign-compare compiler warnings
Fix -Wshadow compiler warnings
Fix -Wcast-qual compiler warning
Fix -Wswitch compiler warning
Remove unused variables
Implement the rbt sample
Use some more descriptive variable names
Verify the oxygen and helium percentage
Add support for the Mares Horizon
Swap the object major and minor version
Fix the Mares Genius memory layout
...
Without the small delay, sending the first frame often fails. Trying to
read the ACK response byte just fails with a timeout, and no data is
received at all. The bootloader is probably not ready to receive data
yet.
The new iX3M 2021 models (refered to as 'iX3M with Sequared Buttons' in
the Ratio support section) identify as iX5M in the Bluetooth name.
Reported-by: Damian Zaremba <damian@damianzaremba.co.uk>
Handling the SIGPIPE signal in a library is tricky, because installing a
signal handler does affects the entire application. But we can at least
try to avoid generating the SIGPIPE signal ourselves. On Linux, that
requires the use of the MSG_NOSIGNAL flag, and on Mac and BSD setting
the SO_NOSIGPIPE socket option.
Because the dive_count variable is decremented, it doesn't contain the
total number of dives, but the index of the last dive. A negative number
indicates no dives. The same result can be obtained by using the total
number of dives directly. That's not only more intuitive, but also fixes
a -Wsign-compare compiler warning.
Windows and unix use a diferent data type for representing socket file
descriptors (SOCKET vs int). This mismatch results in a compiler warning
when comparing to S_INVALID.
Allthough the input buffer size has type 'size_t', the return value of
the function has only type 'int'. Hence the function can't support input
buffers larger than INT_MAX.
This allows to fix a -Wsign-compare compiler warning: operand of ?:
changes signedness from ‘int’ to ‘size_t’ due to unsignedness of other
operand.
The hexadecimal value 0x80000000 is too large to be represented as a
signed 32bit integer. Therefore the default type for the constant is an
unsigned 32bit integer. This is a bit annoying because the timezone
field is actually defined as a signed integer, and thus comparisions
produce -Wsign-compare compiler warnings.
Fixed by switching to INT_MIN, which is the same underlying value but
interpreted as a signed integer.
Comparing signed and unsigned integer expressions can have unexpected
results because the signed integer will get promoted to an unsigned
integer. To avoid the warning, add an explicit cast to the unsigned
type, along with a check to catch negative values.
String literals have the type 'char[N]' by default. Allthough they are
not really 'const', modifying a string literal is undefined behaviour.
Therefore, to avoid mistakes, libdivecomputer uses the -Wwrite-strings
compiler option to change the default type to 'const char[N]'.
The cast that triggers the -Wcast-qual warning can be avoided by using a
character array instead of string literal.
The name of the RBT (Remaining Bottom Time) sample was taken from the
Uwatec dive computers. The actual definition depends on the dive
computer, but it usually corresponds to the air time remaining (with or
without some additional factors taken into account).
The Mares Horizon is a variant of the Mares Genius, with a few changes
to support SCR dives:
The dive header is slightly modified. There is an extra 8 byte field at
offset 0x18, which causes all later fields to have moved up with the
same amount. This difference is indicated in both the object minor
version (with a change from v0.0 to v0.1), and the logformat.
For the profile data, there is a new SDPT sample type which contains a
bit more information compared to the existing DPRS sample type. This
difference is indicated with a change in the object type (from 0 to 1).
The current implementation assumes a fixed order for the record types (a
DSTR record, a TISS record, zero or more DPRS/SDPT records with an AIRS
record every 4 sample, and finally a DEND record), and either only DPRS
or SDPT records but never a mixture of the two. If these assumptions
turns out to be incorrect, the implementation will need to be changed
significantly. Note that the assumption of the fixed order was already
present for the Genius.
Bluetooth support is currently disabled in the Horizon firmware, but
might be re-enabled in the future.
Since logbook entries with invalid ringbuffer pointers are considered a
fatal error, the download is aborted. The result is that any remaining
entries, located after the invalid entry, can't be downloaded at all.
This can be avoided by skipping the problematic entry instead of
aborting the download.
The Sherwood Sage appears to be very similar to the Aeris A300CS. For
the BLE communication the handshake fails and is disabled.
Reported-By: Nick Shore <support@mac-dive.com>
Merge upstream libdivecomputer from Jef:
- support the Scubapro Aladin A2
- improve Cressi Goa support
- parse and report Oceanic firmware versions
* 'master' of git://github.com/libdivecomputer/libdivecomputer:
Report the firmware version in the devinfo event
Refactor the version string matching to use one table
Parse the firmware version
Add support for Cressi Goa gauge and freedives
Add the extra 5 bytes containing the divemode
Add a function to insert data anywhere in the buffer
Add support for the Scubapro Aladin A2
This merges the FIT file parsing extensions to actually parse the
pressure data from the new Garmin Descent Mk2i.
There is more data there about cylinder sizing etc that we can parse,
but this is enough to make things useful. At least for the test cases I
have access to so far.
* Garmin-Mk2i:
Garmin Descent Mk2i: add support for parsing cylinder pressure data
Garmin: add skeleton for the new fields for the Descent Mk2/Mk2i
Very early trial at parsing the pressure data from the Garmin tank pods.
It seems to work for the test-cases I have.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This adds the field definitions, but doesn't actually report the data
yet. But just having the definitions makes the debug output a lot
easier to read through.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
If the caller provides us with a path name, we should not try to connect to the
dive computer via MTP, but instead read the .FIT files from the path provided.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Create parallel helper functions that use libmtp to walk the file tree on the
device and to then read a specific file from the device into our dc_buffer.
MTP is not a file system, it's an object storage, that just happens to allow
object names and parent/child relationships between objects. As a result we
need to remember those file ids for MTP downloads.
The mtp_get_file_list function is rather complex as it includes both the
initial communication with the device and the code to walk the object tree and
then create the list of file.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Breaking things into helper function makes it much easier to then support both
regular file operations and MTP.
This includes some mild whitespace cleanups for consistency.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Just like for the Descent Mk1 this uses the internal Garmin model number (as
indicated in the FIT format) as model, not the USB product ID.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We do this for a few other device where we need slightly different behavior,
depending on the specific model.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
With just a single table, the version string matching not only becomes
simpler, but adding new layouts also requires no code changes anymore.
For devices that need different layouts depending on the firmware
version (e.g. Oceanic Atom 2.0 and Aeris Manta), the table may contain
multiple entries with the different firmware versions. The only
requirement is that the entry with the highest firmware version must be
listed first.
The patterns used for the version string have the firmware version
masked out because it varies. We can re-use those masks to extract the
firmware version.
The gauge and freedives have a slightly different data format compared
to scuba dives. The main difference is the size of the header and two
new sample types.
The logbook header has 5 bytes extra, which are not present in the dive
header. Those 5 extra bytes contain the dive mode, which is required for
parsing the dive data. Therefore, insert all 5 bytes again and update
the parser.
The remaining 4 bytes appear to be some 32 bit address. They are not
used for anything right now, but are preserved as well in case they are
needed in the future.
The memory buffer already supported appending and prepending data, but
not inserting data anywhere in the buffer. That's exactly what the new
function does. The free space is still maintained at either the start or
the end of the buffer.
This actually got broken long ago (and before the new "Subsurface-DS9"
branch: when I converted the Garmin parser to use the generic field
cache, I missed the fact that the parser now cleared _only_ that generic
part of the per-dive cache in between different dives.
The GPS information, and the general dive information would be left
alone in between dives, and could leak from one dive to the next.
Most of the time you don't notice, because dives tend to all have the
same information, so the stale data would get overwritten when parsing
the next dive. But that isn't _always_ true - particularly for the GPS
information, not all the data necessarily always exists.
So clear all the per-dive data when starting to parse a new dive.
This puts the non-gps data all in one sub-structure, so that it's easy
to clear that too in one go - even though that part of the data probably
always does get opverwritten by the new dive data.
Reported-by: @brysconsulting
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>