Compare commits

..

142 Commits

Author SHA1 Message Date
Linus Torvalds
9063bb9e00 shearwater: remove stale remnants of manual string interface code
Minimize unnecessary differences with Jef's upstream code.

The shearwater parser uses the generif field-cache code, and doesn't
need to have the snprintf workarounds for MSC, or include stdio.h etc.
The field-cache code takes care of this.

[ To be precise: the field-cache code _should_ have taken care of this,
  but didn't: it used 'memcpy()' in a macro, but didn't include the
  required header. Removing it from the shearwater code exposed this
  issue with the field-cache header, and this fixes that ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 15:02:00 -07:00
Linus Torvalds
5c64573c83 shearwater: remove unused 'shearwater_common_command()' function
Dirk added this helper in commit 9379004b2df5 ("Shearwater: add helper
to send bytes to the dive computer"), and it was used for a short while
by commit 437cc3e0cc9f ("Shearwater: try to gracefully shut down the
Bluetooth connection").

But then the use was reverted in commit 8120b11258d8, and this helper
function is now stale and unused, and an unnecessary difference to Jef's
upstream code base.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 14:50:19 -07:00
Linus Torvalds
b3b4eb91a2 oceanic: avoid unnecessary difference with Jef's upstream version
We ended up merging Janic McLaughlin's fix for dive truncation issues
into the subsurface branch, and then Jef ended up taking it too, but
making some changes while at it.

See commit 17ff3e066769 ("Oceanic: fix up dive truncation issues, update
memory layout") vs commit 04c367fd0645 ("Oceanic: fix up dive truncation
issues").

The two versions end up doing the same thing, this takes Jef's version
to minimize differences to upstream.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 14:29:17 -07:00
Linus Torvalds
bec9ca9e3c OSTC parser whitespace cleanups
This is pure whitespace cleanup, where the hw_ostc_parser.c file had a
number of lines with eight spaces instead of tabs.  They were right next
to lines with tabs, so it really made no sense.

I only noticed because some of it was arbitrary difference to Jef's
upstream code, and it stood out like a sore thumb when trying to
re-generate our local changes wrt upstream.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 14:08:02 -07:00
Linus Torvalds
c889348583 Remove stale workarounds for MVC from Suunto EON Steel parser
They were for the string field handling, but we now use the generic code
that has those workarounds there. No need for them in the Suunto downloader.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 13:23:19 -07:00
Linus Torvalds
761089c8f2 Remove stale declaration for dc_iostream_get_name()
This function no longer exists, it was subsumed by the new
DC_IOCTL_BLE_GET_NAME ioctl instead.  The declaration for it had just
not been removed when the definition went away.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-05-07 13:12:21 -07:00
Linus Torvalds
8b53c70950 Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull updatream updates from Jef Driesen:

 - work around Pelagic BLE oddity (Oceanic Pro Plus X and Aqualung i770R)

 - OSTC3 firmware update improvements

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Use a more robust command to write flash memory
  Read and cache the firmware version information
  Add an extra delay after writing to the flash memory
  Add an extra delay after erasing a flash memory page
  Send the service init command one byte at a time
  Fix some typos in the comments
  Ignore excess bytes in the BLE version packet
2020-05-07 11:34:33 -07:00
Linus Torvalds
7882ba423c iostream: protect write side against bad custom IO interfaces too
This is the same as the previous commit, just for the write side error
handling.

If we have a bad custom IO low-level driver that returns
DC_STATUS_SUCCESS with zero bytes written, and we have a write() user
that isn't ready for partial writes, we just consider that an IO error.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-13 11:48:35 -07:00
Linus Torvalds
b77e7b6b21 iostream: protect against bad custom interfaces
Jef Driesen points out that the subsurface custom iostream read function
for legacy bluetooth can return a "success" with zero bytes actually
read.  That makes the loop we have to fill up the whole buffer very unhappy.

That's definitely a bug on the subsurface side, but let's also be
defensive about it in the iostream layer.

Note that this happens only when the reader is not able to handle
partial packets (doesn't pass in an "actual" pointer), and we haven't
gotten a full packet yet.

So we'll turn it into a DC_STATUS_TIMEOUT, which is debatable, but the
real fix is for subsurface to not do this in its rfcomm iostream
implementation, and instead return the proper error code.

Reported-by: linuxcrash <albin@mrty.ch>
Debugged-by: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-03-13 09:34:00 -07:00
Linus Torvalds
0714e327b7 Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull upstream libdivecomputer updates from Jef Driesen:

 - fix lack of "end of deco" on DiveSystem iDive computers by reporting
   long NDL values

 - clean up handling of Oceanic empty logbugger

 - fix BLE download for Oceanic Pro Plus X that doesn't like the serial
   number handshake.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Pass infinite NDL values to the application
  Clear the buffer if no dives are present
  Report an error for invalid ringbuffer pointers
  Improve the empty logbook ringbuffer detection
  Skip the BLE handshake for the Pro Plus X
2020-02-27 16:25:31 -08:00
Linus Torvalds
4e809aefd8 Cressi: mark Cartesio and Goa as supporting BLE
They don't actually have any native BLE capabilities, but there's a "HAL
9000" docking station with bluetooth capability (and a USB cable for
wired connectivity).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-16 08:50:38 -08:00
Linus Torvalds
ebbb911427 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream changes from Jef Driesen:

 - fix Oceanic VT Pro date parsing

 - add Sherwood Wisdom 4 and Scubapro Aladin A1 IDs from Janice McLaughlin

 - fix Cressi gasmix index and depth parsing (the gasmix index bit had
   been misparsed as very deep depth)

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Implement the gas mix sample
  Limit the depth value to 11 bits
  Add support for the Scubapro A1
  Add support for the Sherwood Wisdom 4
  Fix the vtpro datetime parsing
2020-02-13 13:03:21 -08:00
Linus Torvalds
ae36b89118 Garmin Descent Mk1: convert to generic field cache
This converts most of the cached data to the field cache, leaving some
garmin-specific fields alone (but removing them from the "cache"
structure in the process).

This means that all of the users of the string fields have been
converted, and we don't have the duplicate string interfaces any more.

Some of the other "dc_field_cache_t" fields could easily be used by
other backends (including some of the partial conversions like the
Shearwater one, but also backends that don't do any string fields at
all), but this conversion was a fairly minimal "set up the
infrastructure, and convert the easy parts".

Considering that the string field stuff still isn't upstream, I'm not
going to push any other backends to do more conversions.

On the whole, the string code de-duplication was a fairly nice cleanup:

 8 files changed, 340 insertions(+), 484 deletions(-)

and perhaps more importantly will make it easier to do new backends in
the future with smaller diffs against upstream.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13 12:53:33 -08:00
Linus Torvalds
752bfaab3d Shearwater: convert predator parser to use generic field interface
This only converts the string fields and the divemode field.

Why? Those were the only ones that were in the proper libdivecomputer
type format: a lot of the other fields are kept in the Shearwater
internal format, and then converted at get_field() time.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13 12:52:11 -08:00
Linus Torvalds
0638482209 Suunto EON Steel: use the generic field cache infrastructure
The only real changes here are some interface updates: several traversal
routines are changed to return 'dc_status_t' which makes more sense in
the libdivecomputer world anyway, and that matches the generic field
cache string routines.

The other changes are also a direct result of the generic code using
slightly different names for the cache fields: they use the same names
as the DC_FIELD_xyz enum to fetch them.

This is not a full conversion to the generic wrappers, and the EON Steel
parser accesses the cache structure directly in several places because
of how the code was written.  That's fine.  Not pretty, but this is all
totally internal to libdivecomputer.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13 12:52:11 -08:00
Linus Torvalds
842592fb55 Extend field-cache infrastructure to support the Suunto EON Steel
This adds a few misc fields that the EON Steel wants, and changes the
string insertion interface to return a 'dc_status_t', which will be used
by that back-end.

The existing deepblu users don't care.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13 12:52:11 -08:00
Linus Torvalds
f73b6836ad Begin making the string interface and "field cache" generic
This starts with the deepblu code, which is the last one I touched.

The next step is to try to make some of the other backends use this too,
and see where the interface isn't quite generic enough.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-13 12:51:57 -08:00
Linus Torvalds
820a797c67 Deepblu Cosmiq+: remove debug error statements
I had sprinkled "ERROR()" statements around in various callchains during
early Deepblu development, and not removed all of them.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-01-28 09:17:14 -08:00
Linus Torvalds
f2f775b9aa Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge Jef's upstream changes:

 - some stream IO abstraction updates: poll() support, but also a new
   ioctl() interface to query the BLE name of the stream instead of our
   own 'get_name()' function.

   This will require corresponding changes on the subsurface side.

 - Jef merged the Oceanic BLE support from me, with changes, and some
   general atom2 backend cleanups.

 - misc small fixups like the 3s Mares BLE timeout we already had.

* git://github.com/libdivecomputer/libdivecomputer:
  Install the ioctl header file
  Advertise the BLE support in the device descriptors
  Fix the BLE device detection for the i770R and Pro Plus X
  Implement the BLE handshaking
  Implement the BLE packet sending and receiving
  Read the entire data packet in a single operation
  Remove the trailing zero byte from all commands
  Fix a bug in the ACK/NAK handling
  Remove an unnecessary function
  Add an ioctl to retrieve the remote device name
  Re-implement the set_latency function as an ioctl
  Add an ioctl function to the I/O interface
  Integrate the new poll function
  Add a poll function to the I/O interface
  Add support for the Oceanic Veo 4.0
  Increase the timeout to 3 seconds
2020-01-26 11:25:54 -08:00
Linus Torvalds
4eb34b1466 Add 'examples/dctool' to git-ignored files
I'm not sure why it wasn't there originally, but it definitely should
be on that list of ignored files, to keep 'git status' happy.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-28 12:01:34 -08:00
Linus Torvalds
60c98fd75b Add back Mares BlueLink Pro bluetooth support tweaks
The Mares BlueLink Pro BLE dongle is the beast from hell, and introduces
lots of extra slowdowns into the Mares communication protocol.

In particular, it turns out that we really can't send the command bytes,
then wait for the ACK byte, and then send the command argument data as a
separate packet.  Because of the delays that the dongle adds, the dive
computer will have given up on the command arguments by the time it sees
them.

At the same time we don't want to always pass the command and arguments
as one single packet in all situations, because at least the Mares
Matrix really seems to want that "wait for ACK before sending
arguments".  See commit 59bfb0f3189b ("Add support for the Mares
Matrix") for details.

So introduce a new "splitcommand" flag, which is set by default, but
gets disabled for the BLE transport case.

Also, because bluetooth is slow, we don't want to ask for big packets of
data.  It seems to cause a buffer overflow on the BlueLink Pro when the
serial data from the dive computer arrives faster than the bluetooth
data can be sent to the downloading side.

So when using the BLE transport, we also limit the packet size to 128
bytes in addition to disabling the command splitting.

With this, I can download hundreds of kB of data from the Mares Quad Air
successfully over BLE.  It's *slow*, but it works.

This is a re-application of commit 5be8c17ea1 ("Mares bluetooth support
tweaks"), with small changes for how the libdivecomputer IO interfaces
have changed in the meantime.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-28 11:48:47 -08:00
Linus Torvalds
3c25c78bae Mares: increase timeout to 3 seconds
The Mares Bluetooth dongle is some seriously messed up stuff, and takes
forever to answer anything.  I'm not sure what we do wrong, because the
Mares mobile App seems to be able to work with it without the excessive
delays, but it is really incredibly slow when we talk to it.

I suspect the dongle has has some "wait until buffer is half full"
timeout, and it then triggers for every command and short reply in both
directions, and there's likely some way to flush it, but I didn't see
anything back when I had one for testing.

Anyway, as a result, one second is just about the latency that the
dongle itself adds regardless of anything else, so when the dive
computer itself needs a timeout to think about things, the overall
timeout needs to be noticeably more than one second.

Three seconds seems to be a somewhat reasonable compromise, and we do
have documentation for it being the right value:

 "Then shalt thou count to three, no more, no less. Three shall be the
  number thou shalt count, and the number of the counting shall be
  three. Four shalt thou not count, neither count thou two, excepting
  that thou then proceed to three. Five is right out."

because we do have strong reasons to believe that the Mares Bluetooth
dongle is a beast from hell.  Everybody who has ecver met it has
certainly gone "Arrrghhh" at some point.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-28 11:35:58 -08:00
Linus Torvalds
778adb37cc Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream Jef.

This is mainly just the (already merged as a separate patch) support for
th eOceanic Pro Plus 4, Jef committed the identical patch but without
marking it as BLE-capable (which is kind of pointless, since it doesn't
seem to work over anything _but_ BLE).

And a couple of trivial fixlets.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the Aeris Manta memory layout
  Add support for the Oceanic Pro Plus 4
  Strip the source directory from file names
2019-12-28 11:32:25 -08:00
Jef Driesen
8711371728 Add initial support for the Oceanic Pro Plus 4
This is _partial_ support for the Oceanic Pro Plus 4 from Jef, based on
a partial dump by John Clark. Quoting Jef in the email thread:

 "I'm not sure why downloading the memory dump fails. All 4 attempts
  fail around the same memory address (0x3140), but not exactly the
  same. Strange, but the good news that there is already enough
  information to figure some things out.

  Linus and Dirk: Attached is a patch with the things I figured out so
  far. Can you make a build for John to try?

  Most of the info looks reasonable, but there are probably still a few
  things missing or wrong. I don't have any ground truth data to compare
  against for things like the temperature sign"

This is that patch for testing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-12-21 07:31:43 -08:00
Linus Torvalds
5290984316 Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef.

Misc small updates all over, the biggest thing (code wise) is probably
the Ratio firmware update support.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Fix the Oceanic Geo 4.0 memory layout
  Ignore all empty logbook entries
  Add a workaround for the hwOS ppO2 firmware bug
  Use macros to encode the firmware version
  Use symbolic constants for the sample types
  Remove the obsolete hwos parameter
  Limit the tank pressure workaround to hwOS devices
  Fix the OSTC tank pressure decoding
  Fix the Scubapro G2 HUD udev rule
  Add the Mares Genius to the bluetooth filter
  Add firmware upgrade support for the Ratio computers
2019-12-21 07:27:54 -08:00
Linus Torvalds
426a39fc73 Merge upstream git://github.com/libdivecomputer/libdivecomputer
Merge misc fixes from Jef's upstream.

This fixes the incorrect and partial Oceanic Geo 4.0 support from commit
e38406b353bb ("Start adding IDs for the Oceanic Geo 4.0"), where I was
assuming it looked like the I770R.

* https://github.com/libdivecomputer/libdivecomputer:
  Add support for the Oceanic Geo 4.0
  Fix a buffer overflow
2019-10-24 05:55:35 -04:00
Linus Torvalds
d3ccb88a44 Merge git://github.com/libdivecomputer/libdivecomputer.git into Subsurface-NG
Merge upstream updates from Jef Driesen:

 - clean up Shearwater tank pressure handling

 - minor fixlets

The Shearwater pressure sensor changes by Jef means that I also changed
how we handle the battery level for the pressure sensors, and integrated
it with the tank handling.

* jef/master:
  Improve the support for multiple tank transmitters
  Extract the log version immediately
  Use a struct for the gasmix data
  Use a prefix match for the Suunto bluetooth name
  Update the Shearwater Nerd bluetooth names
  Check condition before entering the loop
2019-10-13 11:19:08 -07:00
Linus Torvalds
ce6d9896a7 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef:

 - Jef took my i200C support patch, so merge that up (only difference
   was that we mark it as BLE-capable)

 - support for multiple cylinders and transmitters for the Ratio iDive
   dive computers

 - Fix Mares BLE packet cache missed invalidation

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Discard the cached BLE packet
  Add support for Aqualung i200c
  Take the tank transmitter flags into account
  Add support for multiple tank transmitters
  Use a struct for the gasmix and tank data
2019-09-07 09:40:10 -07:00
Linus Torvalds
2d40cf46b1 Deepblu Cosmiq+: flesh out some of the comments and fingerprint size
I've tried to find where the firmware version and serial number are, and
have failed miserably.  Some of the commands I have sent instead cleared
the memory of the dive computer.  Whee.

But let's document the responses to the commands anyway, and flesh out
the fingerprinting code (which is useless without a device ID, which we
do not currently have).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 13:45:34 -07:00
Linus Torvalds
d532be187a Deepblu Cosmiq+: stop downloading once we've seen the dives already
.. and also support cancellation of dive downloading in the middle.

The Cosmiq+ doesn't remember all that many dives, but BLE is slow and
there's no point in downloading more than necessary.

I'll look at fingerprinting next, so that we can avoid downloading the
profile data if we have already seen the header.  That's a further small
optimization.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 12:19:32 -07:00
Linus Torvalds
df7aeeef01 Deepblu Cosmiq+: fix oxygen percentage reporting
When I added more parsing of the dive data of the Cosmiq+ in commit
4dff291a1a53 ("Deepblu Cosmiq+: fill in some parsing details") I got the
gasmix units completely wrong and clearly never tested it.

The DC_FIELD_GASMIX reporting uses floating point percentages, not
integer percentages, and instead of reporting 21% as 0.21, we used to
report it as 21.0.  It all looked fine in my profiles, because I'd only
tested simulated air dives, and subsurface defaults to air even if
somebody reports crazy impossible gases.

Easy enough to fix, and now actually tested by doing a simulated nitrox
dive.

Reported-by: Michael Werle <mwerle@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-27 11:58:08 -07:00
Linus Torvalds
aab3d7a68e Add support for Aqualung i200c
It's exactly the same as the regular i200, but has a new version number
and string.

Tested-by: Tiago Thedim Dias <tiagotsoc@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-24 13:39:01 -07:00
Linus Torvalds
32e6ae4efa Deepblu Cosmiq+: fix missing prototype
Apparently I never added the new deepblu.h header file to the parser,
and never noticed.

But then Travis complains on the iOS build. Good catch, Travis.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-19 12:39:08 -07:00
Linus Torvalds
ccef003d47 Deepblu Cosmiq+: add progress reporting for downloading
Note that the fingerprinting code hasn't been connected yet (I'm n ot
entirely sure what I should compare - the whole 36-byte dive header?),
and it currently always downloads all dives on the Cosmiq+.

Not that that much matters, since there aren't all that many dives that
fit on it, but it's worth pointing out the current weaknesses of the
code.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 14:29:02 -07:00
Linus Torvalds
4dff291a1a Deepblu Cosmiq+: fill in some parsing details
This adds support for the different modes (scuba/gauge/freedive) and
teaches the parser to set the right sample interval and get the dive
time right.

In freedive mode, the sample interval is 1s, and the dive time is in
seconds too.  In the other modes, the sample interval is 20s, and the
divetime is in minutes.

Also set the right gas for scuba.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-18 13:50:50 -07:00
Linus Torvalds
eacfe4011a Deepblu Cosmiq+: add basic dive information parsing
This at least approximates downloading a dive from the Deepblu Cosmiq+,
and gives reasonable profiles for my test-dives (in a dive computer
chamber, not real dives).

I'm sure there's a lot to be improved here, and this literally only gets
depth and water temperature, but that seems to be what the Cosmiq+ gives
us.

Lots of credit to Michael Werle for bluetooth packet captures, and some basic analysis of the protocol.

Packet-logging-by: Michael Werle <mwerle@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-17 15:06:16 -07:00
Linus Torvalds
2efa83eeee Deepblu Cosmiq+: start downloading dive data
This actually seems to download all the data.  It just doesn't parse any
of it yet, so you get just empty dives.  But the basic packet and data
transfer seems to work.

Now I need to fill in the details on the actual dive parsing side, and I
should see a profile.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-17 11:53:25 -07:00
Linus Torvalds
4ce0ae9e4f Deepblu: add basic send/receive functionality
This was tested with a command to set the time and date, but only the
actual IO parts are here.

The packet format is fairly simple, even if it's not exactly clear why
everything is HEX-encoded.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-16 14:09:28 -07:00
Linus Torvalds
9812bf0828 Deepblu Cosmiq+: Add skeleton code
This does nothing at all, but it adds all the core skeleton
infrastructure for the Deepblu Cosmiq+ dive computer.

Let's see if I can make sense of things and make it download anything.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-08-15 14:46:38 -07:00
Linus Torvalds
ffbb472975 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer updates from Jef:

 - Add support for the Aqualung i550C

 - Update Ratio iX3M GPS naming and note that they support rfcomm

 - misc cleanups

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Aqualung i550C
  Enable bluetooth support for the Ratio iX3M GPS
  Update the naming of the Ratio iX3M GPS range
  Mark the string tables as constant
  Refactor the filter functions
2019-07-14 17:34:38 -07:00
Linus Torvalds
1bbd386959 Merge git://github.com/libdivecomputer/libdivecomputer
Merge upstream libdivecomputer updates from Jef:

 - Support the new versions of the Mares Genius with more memory

 - misc small fixes (Pelagic/atom2 tank pressure fix, proper error
   codes, license info for AES code)

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the tank pressure reporting
  Return the correct error code
  Add support for the Mares Genius
  Simplify the detection of air integrated models
  Refactor the gas mix and tank parsing
  Refactor the date/time parsing
  Replace the header offset with the header size
  Use symbolic constants for the commands
  Add license information to the AES code
  Update the udev rules
2019-07-04 10:50:17 +09:00
Linus Torvalds
b9d72607a8 Garmin Descent Mk1: add more informational debug output for file accesses
It turns out that it's fairly common that people pass in the wrong
directory for the Garmin downloader, and we then just silently fail to
parse any dives because we don't find anything.  The resulting logs
don't make it obvious what went wrong.

So add some informational messages about what directory we actually
tried to open, and what files we've found (and why we possibly ignored
them).

We already had this for some cases (like "This doesn't look lik ea dive
file"), but not for the more fundamental issues of not finding files to
begin with.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-31 13:17:48 -07:00
Linus Torvalds
e38406b353 Start adding IDs for the Oceanic Geo 4.0
There's a new dive computer in town: the Oceanic Geo 4.0.  It looks like
it should support BLE, and is probably fairly similar to the Pro Plus X.
Or so this initial support trial just assumes.

I don't have the version string for this device yet, so that hasn't been
added at all.  A full dump is required, the initial report only (almost
accidentally) gave the model numbers thanks to the BLE scan data.

Reported-by: George Rocks <jrroques2004@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-31 10:03:06 -07:00
Linus Torvalds
8fb2b75c25 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge Jef's upstream updates.

Trivial conflicts just because of whitespace differences and a comment
difference in our Suunto D5 support changes.

* git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Suunto D5
  Add support for the Tusa Talis
  Add the G2 HUD bluetooth device name
  Detect Mares Quad with more flash memory
  Fix the limit for an invalid sample temperature
  Fix a buffer overflow
2019-05-31 09:49:17 -07:00
Linus Torvalds
1194585595 Add support for Suunto D5 dive computer
It looks just like a small-form-factor EON Steel/Core, just with new
device IDs.

I haven't been able to pair over BLE yet, but that may be the usual
"Suunto wants to do a private bonded pairing" thing that makes it a pain
on the desktop.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-16 14:42:22 -07:00
Linus Torvalds
92cf2f8fa1 Suunto EON Steel/Core: make sure to properly sort the dive list
I incorrectly thought it was already sorted in the directory listing,
but once the dive list start overflowing, it looks like the ordering
goes away.

So sort the dives explicitly by date, rather than depend on any existing
ordering when reading the list of dives.

Reported-by: PM <boesch76@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-05 14:19:43 -07:00
Linus Torvalds
e650acc052 Garmin: be more permissive about the activity type
We used to require that we have one of the documented dive types in the
'sub_sport' type field.  But apparently Garmin added a new type number
for CCR diving, so CCR dives weren't recognized at all.

Add the new CCR case, but also say that if we have seen a DIVE_SUMMARY
record with average depth information, we'll just assume it's a dive
even for unrecognized sub_sport numbers.

Reported-by: Thomas Jacob <opiffe@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-05-05 10:00:27 -07:00
Linus Torvalds
2971cc20ff Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull upstream updates from Jef Driesen.

This adds ID entries for the Scubapro G2 HUD (but no GPS parsing support
yet) and the Aladin H Matric.

Also fix ndl/deco parsing for for Aqualung i450T.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the ndl/deco sample for the Aqualung i450T
  Add support for the Scubapro G2 HUD
  Add support for the Scubapro Aladin H Matrix
2019-04-24 09:04:42 -07:00
Linus Torvalds
c7112237b3 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream updates from Jef:

 - better Mares Bluelink Pro downloading

 - Suunto DX CCR and gas mix fixes

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Mares Bluelink Pro interface
  Check the correct vtable pointer
  Report the setpoint data
  Take the CCR diluents into account
  Implement the initial gas mix
  Get the gas mix index directly from the event data
2019-04-15 08:53:33 -07:00
Dirk Hohndel
e4698c4844 Shearwater Teric: add support for the TAG INFO_EVENT
This logs every INFO_EVENT record and provides a SAMPLE_EVENT_BOOKMARK event for
the only INFO_EVENT we can parse so far, the TAG event. Three bits in the flag
value in that event structure are now used to hold the tag type, and if a
non-zero type has been set, then the value is the heading in degress.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2019-03-16 12:23:28 -07:00
Linus Torvalds
d0ec5cf760 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream from Jef:

 - ignore empty pressure samples from OSTC

 - skip empty Oceanic logbook entries

 - update Ratio parsing

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Ignore zero tank pressure values
  Add filters for BLE communication
  Skip empty logbook entries
  Add clock synchronization support
  Use symbolic constants for the commands
  Don't pass a NULL pointer to memcpy
  Update the list of the Ratio dive computers
2019-03-12 17:00:19 -07:00
Linus Torvalds
1953d7a5a1 Shearwater: fix (again) per-cell ppO2 reporting
This re-applied commit 902dbf4d6d24 ("shearwater: Fallback to
average/voted ppo2") which got lost in the last merge with upstream when
I synced with Jef's rewrite of the PNF parser.

Reported-by: Martin Long <martin@longhome.co.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-03-12 16:55:25 -07:00
Linus Torvalds
072bef1666 shearwater: properly initialize the string caches
The merge with Jef's upstream ended up taking a lot of Jef's changes to
how the Shearwater PNF parsing was done, and in the process inadvertdly
lost some of the code from our side of the branch that Jef hadn't taken.

In particular, the initialization of the string cache, and the
logversion string.

Put them back.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-23 13:28:39 +13:00
Dirk Hohndel
391c4095f2 Shearwater parser: add new harware model nr for Teric
As of firmware 11 at least my Teric identifies as 0x1F0A.
Also, just like libdivecomputer upstream, don't assume that an unknown
model is a Petrel - that was a stupid thing to do and caused downloads
with the Teric to break.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-01-23 09:08:10 +13:00
Linus Torvalds
1d09635a58 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Update with Jef's upstream:

 - add support for Cressi Goa and Cartesio

 - update the Shearwater PNF parser to Jef's version

 - misc minor fixes

* git://github.com/libdivecomputer/libdivecomputer:
  Use the timezone setting of the dive computer
  Add support for the Cressi Goa and Cartesio
  Add an extra parameter for the initial CRC value
  Add support for the Ratio iDive Color series
  Shearwater Petrel Native Format parsing
  Shearwater: detect which logbook format is support
  Shearwater: add Teric to list of supported dive computers
  Shearwater: skip deleted dives
  Fix a potential buffer overflow
2019-01-22 12:15:37 +13:00
Linus Torvalds
e4c96e93ca Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream from Jef.

Small trivial fixlets.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Fix the Cobalt 2 memory size
  Use the travis homebrew plugin to install packages
  Increase the internal log buffer
  Fix undefined behaviour in left shifts
2018-12-17 09:32:47 -08:00
Linus Torvalds
33253b2f8c Fix OCEANIC_COMMON_MATCH pattern matching for BLE versions
It seems that the BLE communication protocol is somewhat different from
the serial one in the version string: while the serial version tends to
show the memory size, the BLE version string has some other numeric
pattern.

We don't have enough information to guess what it is, although normally
the BLE pattern is just "0001" instead of some memory size string.  But
I've seen the i770R once report 0090 instead.  Some status code?

Regardless, make the Pro Plus X and the I300C pattern simply ignore the
last four digits, since they clearly vary, and those two computers
support BLE.

The i770R pattern already did that, since I saw it myself.  The Pro Plus
X I have a communication trace from Brett Woods, and the i300C I just
assume follows the same pattern.

Reported-by: Brett Woods <brett@jeepswag.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-17 09:24:24 -08:00
Linus Torvalds
b082a96ebb Enable BLE support for the Oceanic Pro Plus X
It really looks (very superficially) like the Oceanic Pro Plus X might
act exactly the same as the Aqualung i770R over bluetooth: it has the
exact same bluetooth name pattern ("ER001299", where "ER" is the ASCII
represetnation of the model number (0x4552) and the 001299 looks like
the serial number that we then use for "authenticating" with the device.

I haven't actually tested this at all, but Brett Woods sent the
bluetooth scan information, and it looks promising.  So let's just test
it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-12-14 13:45:17 -08:00
Linus Torvalds
e34e211c3e Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Sync up with Jef's upstream changes.

About half of it was stuff we'd already done: i770R support (together
with the Oceanic dive truncation) and the change to the Scubapro G2 BLE
protocol.

And once again, Jef has taken the work of others (me and Janice) and
made pointless changes to it just to make merging harder.

And once again, I tried to match up with upstream as much as possible to
make future merges easier.  But it annoys me.

This *may* also get the Aqualung i300C working over bluetooth.  I have
no real way to test, but the basic parsing support is there thanks to
Jef, and Janice implied that the BLE handshaking is the same as the
i770R.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Aqualung i300C
  Add support for the Aqualung i770R
  Fix the Pro Plus X gas mixes
  Oceanic: fix up dive truncation issues
  Scubapro G2: update BLE downloading for new 1.4 firmware version
  Add a workaround for invalid ringbuffer begin pointers
2018-12-02 11:52:06 -08:00
Linus Torvalds
abde311d3a Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull upstream updates from Jef Driesen.

This is mainly the Pelagic (Oceanic, Sherwood, Aeris, Aqualung etc)
download interface reset sequence.

* https://github.com/libdivecomputer/libdivecomputer:
  Fix the RTS signal handling for Pelagic interface
  Fix a memory leak in the error handling
2018-11-14 10:55:31 -06:00
Linus Torvalds
f0fe141373 Scubapro G2: update BLE downloading for new 1.4 firmware version
The packetization format for the BLE communication used to be that the
first byte of the BLE GATT payload was the size of the payload (1-19
bytes).

That seems to no longer be true as of fw version 1.4.  It is still the
size of the payload for the simple small reply packets, but for the long
data stream it ends up being an odd sequence of 13 different values that
are almost - but not quite - 19 apart.

Whatever.  Modify our strict "length byte must make sense" rule to be
more of a guidline than a hard rule.  This makes the download succeed
again.

Very weird.

Reported-by: Adric Norris <landstander668@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-08 12:09:50 -07:00
Linus Torvalds
e61b7c64f9 Aqualung i770R (and i300C): do proper BLE handshake packet
The "I have NO IDEA" 0xE5 command seems to be a handshake packet with a
passphrase based on the serial number of the device.

Sadly, we can't actually read the serial number from the device until
after this handshake as successfully completed, which makes it a bit of
a chicken-and-egg problem from a communication standpoint.

However, the serial number is also exposed in the bluetooth name that
the device advertizes, which is the reason for the newly added
"dc_iostream_get_name()" function - so that whoever set up the IO for us
can give us the name.

Annoying, yes, but less annoying than "I have NO IDEA".

Thanks to Janice McLaughlin for pointing out the logic of this magic
handshake, which is apparently also the case for the Aqualung i300C.

This also simplifies the command sequence handling: if you use
oceanic_atom2_ble_transfer() and ask for an answer (even if the answer
size is zero, and only the ACK is returned), the BLE transfer code will
handle the sequence number on its own.

Only if you send a packet without expecting an answer at all do you need
to manage the sequence number manually.  This is mainly used for
oceanic_atom2_device_write(), although I suspect that code gets an ACK
and could use a zero answer size too.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-06 14:00:35 -07:00
Linus Torvalds
54ba49b1b3 iostream: add 'get_name()' function
Some of the transport types have meaningful names.

The BLE transport has a device name that was exposed during device
discovery, for example, and some back-ends (ok, right now only the
Aqualung i300C and i770R) need to know what that device name was in
order to handshake with the device properly.

Other transports, like the USBSTORAGE one, could usefully use this to
get the basename of the path to the storage, although right now that
transport makes do with simply doing a "dc_iostream_read()" on the
transport instead.

For now, this is just the infrastructure, ready to get hooked into.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-05 15:04:37 -07:00
Linus Torvalds
65ef99981f Aqualung i770R: _really_ fix the gas mix parsing
Commit fac3c8ff1487 ("Aqualung i770R: fix up gas mix parsing") was
supposed to fix gasmix parsing for the i770R, but because Janice's patch
didn't apply as-is, I had just redone it by hand, and in the process
copied the wrong o2_offset for the i770R, giving (not surprisingly) the
wrong results.

This just fixes my copy-paste error to what Janice actually had
originally.

Mea culpa.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-05 15:04:37 -07:00
Linus Torvalds
419b0e0498 Garmin Descent: make sure to open FIT file with O_BINARY if it exists
Primoz seems to have problems downloading dives from the Garmin Descent,
even when the same files work fine for me.  I suspect it's some Windows
issue, and the primary suspect would be the usual CR/LF text conversion.

Using O_BINARY would seem to be the obviously correct thing to do, and
won't hurt.

Reported-by: Primoz P <primozicp@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-05 11:52:03 -07:00
Linus Torvalds
5456475fd5 Garmin Descent: add heartrate parsing
.. the parsing was actually already there, but we never generated the
event to report it. I hadn't had any files with HR data.

Reported-by: Primoz P <primozicp@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-05 11:52:03 -07:00
Janice McLaughlin
fac3c8ff14 Aqualung i770R: fix up gas mix parsing
It appears that the Aqualung i770R looks almost the same as the ProPlus
X, but has an additional pO2 field for each gas by the O2 field, which
impacts the offset calculations.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-04 10:06:54 -07:00
Janice McLaughlin
17ff3e0667 Oceanic: fix up dive truncation issues, update memory layout
This fixes the dive truncation that happened with long dives due to the
removal of extra padding (commit a2100843b9cf: "Remove extra padding
from the end of the profile").  It turns out the rest of the profile was
in bits 13-15 (with bit 12 being something else).

Also update the memory layout and the baudrate for the i770R.

Signed-off-by: Janice McLaughlin <janice@moremobilesoftware.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-02 16:09:56 -07:00
Linus Torvalds
2518231577 Aqualung i770R: add packet send retry on reply failure
It seems to make things more robust.  Without this, the first packet in
particular seems to easily get lost, and the retry gets things going
again.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-01 16:21:42 -07:00
Linus Torvalds
c6c29f6e9a Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull fix from Jef's upstream.

This fixes the end of dive garbage for newer Aqualung dive computers,
including the i770R.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Remove extra padding from the end of the profile
2018-10-01 15:19:52 -07:00
Linus Torvalds
07a33e88c3 First attempt at supporting the Aqualung i770R
This works over BLE, although the end result of a dive download is still
a bit wonky.  There remains some parsing problem that Jef says are
likely be common with the Pro Plus too.

The serial download doesn't work at all, for unknown reasons.  That
*should* be the easy part that "just works" and acts the way previous
similar dive computers have acted.  It's a standard FTDI chip (FT231X)
that exposes a serial connection, but there may be some setup required
to choose between USB and BLE that we do not know about right now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-30 10:08:06 -07:00
Linus Torvalds
5be8c17ea1 Mares bluetooth support tweaks
So it turns out that we really shouldn't send the command and arguments
as one single packet in all situations, because at least the Mares
Matrix really seems to want that "wait for ACK before sending
arguments".  See commit 59bfb0f3189b ("Add support for the Mares
Matrix") for details.

Also, because bluetooth is slow (and it looks like it's particularly
slow for us with the Qt bluetooth code for some reason), we don't want
to ask for big packets of data, because it seems to cause a buffer
overflow on the BlueLink Pro when the serial data from the dive computer
arrives faster than the bluetooth data can be sent to the downloading
side.

So when using the BLE transport, limit the packet size to 128 bytes and
disable the command splitting.

With this, I can download hundreds of kB of data from the Mares Quad Air
successfully over BLE. It's *slow*, but it works.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-27 10:48:15 -07:00
Linus Torvalds
f57c53470b Mares Icon HD family: send the command as one single write buffer
The Mares backend used to send the commands by splitting them up into
the two-byte command and the "rest", while waiting for the ACK byte
(0xAA) to come in between the two parts.

That seems to work fine for the serial side, but the the BLE packets, it
seems to cause too much of a delay between the command bytes and the
argument bytes, and the end result is that the Mares doesn't actually
act on the argument bytes at all, and just sends an EOF reply (0xEA).

The Mares app itself does seem to send them as two packets, but
apparently without actually waiting in between, avoiding the issue.

Let's just send the command as a single write, which makes at least my
loaner Mares Quad Air with the BlueLink Pro dongle happy.

We may need to revisit the details of this based on feedback.  But it
should speed up downloading too, by avoiding the roundtrip wait for the
ACK byte.

This affects all the computers in the Mares Icon HD family: Matrix,
Smart, Smart Apnea, Icon HD, Icon HD Net Ready, Puck Pro, Nemo Wide 2,
Puck 2, Quad Air, Smart Air and Quad.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-26 17:45:42 -07:00
Linus Torvalds
e97886a994 Fix dc_iostream_{read,write} debugging implementation
The dc_iostream_{read,write}() implementation had multiple issues:

 (a) it would return DC_STATUS_SUCCESS even if no iostream
     implementation existed.

     Yes, it would also return a zero "actual" bytes, but most backends
     don't even pass an "actual" pointer, so returning success was still
     completely insane.

     This one probably didn't matter, because all iostreams should have
     read and write members, but the return value was completely wrong
     if that ever were to happen.

 (b) The write side actually tested not whether a write function
     existed, but whether a read one existed.

     Again, this one probably didn't matter in practice, since an
     iostream without a read and write member doesn't make much sense,
     but the test was completely wrong regardless.

 (c) If the user passed in a NULL 'actual' pointer, the wrapper would
     ignore that, and pass in its own pointer instead, in order to know
     how many bytes to print for the debug message.

     But that means that the low-level read/write functions cannot know
     whether the user actually is able to handle a partial read or not.

     This one _definitely_ matters, because some protocols need to have
     a buffer for the whole incoming packet, but packerts may not always
     be full-size. The low-level protocol needs to know whether to wait
     for further packets (in order to fill the buffer) or to just return
     the partial data.

This fixes all of these issues.  If the user passes in a NULL actual
pointer (indicating that it needs all-or-nothing and is not ready to
handle a partial success), just loop over the IO until the buffer is
fully exhausted.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-26 11:22:23 -07:00
Dirk Hohndel
8120b11258 Revert "Shearwater: try to gracefully shut down the Bluetooth connection"
This reverts commit 437cc3e0cc9f88eedf27657c485cd55f23a4f2df.

Jef convinced me that this is fundamentally the wrong thing to try here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-25 16:44:56 -07:00
Dirk Hohndel
32d62d6269 Shearwater: fix incorrect parsing of base address
I misunderstood the way the helper function worked. Thanks Jef for
pointing it out. The way I wrote the code we ended up doing undefined
shifts which explains why the data I got back seemed so random.

With this we should be able to simply act on the four known values for
the base address, with 0xDD000000 never an option by the time you got
here - but in the old code (prior to the PNF addition) we would have
fallen back to 0xC0000000, so let's do the same here.

Any other value is actually an unknown format and should be treated as
such.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-25 16:44:56 -07:00
Dirk Hohndel
91766d1ed0 Shearwater: better macro name
As Jef correctly points out, RDBI actually stands for Read Data by
Identifier, and the correct identifier here is Log Upload.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-25 16:44:56 -07:00
Linus Torvalds
f705ddefa8 Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Pull Aqualung i100 support from Jef's upstream libdivecomputer.

Very similar to the I200, but with the header in a different location.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Add support for the Aqualung i100
2018-09-24 12:25:11 -07:00
Linus Torvalds
0d1e8f1803 Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer changes from Jef Driesen.

A harmless build cleanup, and a small fix for the Mares Smart Apnea
temperature parsing.

* git://github.com/libdivecomputer/libdivecomputer:
  Fix the Mares Smart Apnea min/max temperature
  Fix the libusb and hidapi includes
2018-09-21 14:33:18 -07:00
Linus Torvalds
6f377182f5 garmin: relax FIT filename rules for Descent Mk1
When on the actual watch, the filename format for the FIT files ends up
being something like

    2018-09-21-10-23-36.fit

but then if you download the activity from the Garmin Connect activity
website, it might show up as a ZIP file that contains a file named
something like

    3030954326.fit

instead.

In order to make it easy to import these fit files that have been
downloaded from the Garmin cloud, relax the filename rules a bit.

NOTE! You still need to have the proper directory structure, and put
your FIT files in a subdirectory like

  <some path>/Garmin/Activity/

to match the way the FIT files show up when you mount the Garmin Descent
locally.  You can then point subsurface to <some path> when you do a
"download" from the Garmin Descent, regardless of whether it's an actual
case of the dive computer being mounted, or if you've downloaded the FIT
files to your local filesystem.

Reported-by: Andrew Trevor-Jones <atj777atj777@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-21 14:31:20 -07:00
Dirk Hohndel
fb70928c83 Shearwater parser: fix typo in Teric support
The surface pressure was read from the wrong location for PNF logs.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-18 15:09:14 -07:00
Linus Torvalds
8f2ac8f61e Merge branch 'teric' of git://github.com/Subsurface-divelog/libdc into Subsurface-NG
Merge Dirk's Shearwater Teric branch.

The Teric only supports Shearwater's new download format (PFN - Petrel
Native Format), and the old legacy format no longer works.

I'm sure there are issues, and Dirk just ended up ignoring an
unexplained format difference on Android, but without this you get
nothing.

[ Fixed up a format warning in the merge commit  - Linus ]

* 'teric' of git://github.com/Subsurface-divelog/libdc:
  Shearwater PNF support: fall back to default logbook style
  Shearwater: report error when parsing freedive
  Shearwater: add Teric to list of supported dive computers
  Shearwater: try to gracefully shut down the Bluetooth connection
  Shearwater: add helper to send bytes to the dive computer
  Shearwater Petrel Native Format parsing
  Shearwater: use the correct address to download dives
  Shearwater: detect which logbook format is support
  Detect Sherwater Teric
  Shearwater: skip deleted dives
2018-09-12 09:12:10 -10:00
Dirk Hohndel
348387c6f6 Shearwater PNF support: fall back to default logbook style
On Android we appear to mis-interpret the response to the RDBI command.
Instead of failing, fall back to the default value (PNF for Teric,
Predator-like for everything else).

With this I can successfully download dive data from my Teric on
Android.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-12 10:54:39 -07:00
Linus Torvalds
5ad97bd6bb Suunto EON Steel: report TTS now that libdivecomputer has the interface
The data was always there, and we used to report it as the length of the
next deco stop, which didn't make much sense, but it was basically the
only interface that libdivecomputer had.

Now that we've added DC_SAMPLE_TTS, report TTS properly, and just report
the deco stop time (which the EON Steel doesn't actually give us) as one
minute whenever we have a ceiling.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-09 11:54:15 -07:00
Dirk Hohndel
ee7c14ecc3 Shearwater: report error when parsing freedive
Support for the 8 byte freedive samples has yet to be added. For now bail out.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 18:44:00 -07:00
Dirk Hohndel
d0a3336c82 Shearwater: add Teric to list of supported dive computers
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 18:37:50 -07:00
Dirk Hohndel
437cc3e0cc Shearwater: try to gracefully shut down the Bluetooth connection
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 18:37:50 -07:00
Dirk Hohndel
9379004b2d Shearwater: add helper to send bytes to the dive computer
This should allow us to gracefully shut down the communication with BLE devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 18:37:50 -07:00
Dirk Hohndel
34785f55ff Shearwater Petrel Native Format parsing
This will allow parsing dives from the Shearwater Teric, but depending on the
firmware could also be used on older models.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 18:37:50 -07:00
Dirk Hohndel
0cbcc0518c Shearwater: use the correct address to download dives
Replace the hardcoded address which the one we determined based on the logbook
type available.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 17:34:42 -07:00
Dirk Hohndel
f80024ed59 Shearwater: detect which logbook format is support
RDBI response tells us which format the dive computer supports.

Shearwater recommends to use the 'Petrel Native Format' for all dive computers
which support it, even those pre-Teric models which (depending on firmware)
might support both PNF and the older 'Predator-Like Format'.

They also recommend to ignore the 0x90...... format which is very similar to
PNF but without the final record and to use the older Predator Like Format in
that case.

Which format we use is determined by the base address used to download the
logbook entries.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 17:34:34 -07:00
Dirk Hohndel
12b90c693a Detect Sherwater Teric
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-08 17:26:21 -07:00
Dirk Hohndel
ec0029c4ce Shearwater: skip deleted dives
Without this change a deleted dive on device is treated like the end of the
dive list.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-09-07 17:08:26 -07:00
Linus Torvalds
a9c582e26f garmin: parse dive setting information fields
Based on information from Ryan January, who got it from his Garmin
contacts and got the go-ahead to share the data.

This is mainly the water density and deco model.  It has a few other
fields troo, but nothing necessarily worth reporting.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-05 18:22:07 -07:00
Linus Torvalds
c1c0303e04 garmin: update event descriptions
Based on information from Ryan January, who got it from his Garmin
contacts and got the go-ahead to share the data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-05 17:49:51 -07:00
Dirk Hohndel
7779bdf581 Garmin: don't assume that the first device index is 0
While it seems like a safe assumption, the cost of being careful and assembling
the full record and taking the one for device_index 0 seems worth it to me.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-05 11:41:55 -07:00
Dirk Hohndel
416bf35977 garmin: adjust the model to reflect the FIT product code
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-04 17:54:36 -07:00
Dirk Hohndel
e02037bf84 garmin: extract the devinfo from the first FIT file we parse
A typical FIT file contains several DEVICE_INFO messages.  We need to
identify the one(s) for the creator (i.e.  the actual device, not a
sub-component).

Note, Garmin identifies the Descent Mk1 as product 2859.  I think we
should use this as the model number (instead of currently using 0.

Also, the vendor event is not to send the vendor name of the device, but
in order to send vendor specific events :-)

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-04 17:54:33 -07:00
Dirk Hohndel
ac25976258 garmin: ignore FIT files that aren't dives
Dives are identified by a sub_sport range of 53-57 in the SPORT message.

This means that we need to parse the files before we actually offer them to the
application, which means we parse them three times all together, but I don't
see a way around that. Thankfully parsing a memory buffer is reasonably fast.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-04 17:53:36 -07:00
Linus Torvalds
41303bbc70 garmin: improve on debug log output for unknown fields
Yes, the hexdump was simple, but it was really hard to read, and we can
do so much better, including taking empty data into account, and
formatting it by the actual size of the individual fields.

So this improves on the debug log, so that when we decide to try to
parse new field information, the data will be in a somewhat more legible
format that makes more sense.  And getting rid of the empty fields makes
it much clearer what data might be even remotely interesting.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-04 17:18:37 -07:00
Linus Torvalds
8f7e29e1f9 garmin: start decoding notifications and gas change events
The magic numbers in the decoding are all based on Wojciech Więckowski's
fit2subs python script.

The event decoding is incomplete, but it should be easy enough to add
new events as people figure them out or as the FIT SDK documentation
improves, whichever comes first.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-02 20:17:30 -07:00
Linus Torvalds
740222d216 garmin: don't suppress the time sample at zero time
The logic to suppress multiple redundant time samples in the garmin
parser also always suppressed the time sample at 0:00, which was not
intentional.

Fix it by simply making the "suppress before" logic be "suppress until"
instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-02 14:09:52 -07:00
Linus Torvalds
4a43392c78 Garmin: add DC_SAMPLE_CNS reporting
The code to parse it was already there, we just didn't report it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-02 13:31:51 -07:00
Linus Torvalds
86540206db Add support for DC_SAMPLE_TTS - time to surface in seconds
Several dive computers support this, so why not have the proper
interface for it in libdivecomputer?

Triggered by the fact that the Python scripts to generate XML files from
the Garmin FIT files can import this information, but the native
libdivecomputer model couldn't.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-09-02 13:16:02 -07:00
Linus Torvalds
f6ea5f514a Merge branch 'garmin-descent' into Subsurface-NG
Merge the initial Garmin Descent Mk1 support.

This actually works well enough to be useful, even though there are a
few ugly details yet to be sorted out.

The download itself is fairly complete, but all event handling is
currently missing (warnings, gas changes, things like that).

Also, because of how libdivecomputer works, the "downloading" of dives
is entirely separate from the "parsing" of dives in the libdivecomputer
world.  And that is actually problematic for the Garmin Descent
downloader, because you actually need to parse the data to even figure
out whether it's actually a dive at all!

The Garmin Descent is also a fitness and general excercise tracker, so
people can (and do) use it for other sports than just diving, and so the
activities we download may end up not being dives at all, but other
events.

But before we parse them, we don't know, and we aren't really supposed
to parse them until after we've passed the data to the application and
it passes it back for parsing.  Nasty chicken-and-egg problem there..

So right now non-diving activities will just show up as very short
and/or shallow dives.

This is fixable by just parsing things an extra time, but I really wish
libdivecomputer would just stop thinking that downloading and parsing
are separate events.

* garmin-descent:
  Add dc_usb_storage_open to the symbols list
  garmin: only record gasmixes for cylinders that aren't enabled
  garmin: don't emit fake device info and vendor event
  garmin: add support for downloading gas mixes
  garmin: add GPS coordinate data and improve parser_get_field() reports
  garmin: actually start using the parsed data
  garmin: turn all the remaining unrecognized fields into DEBUG messages
  garmin: add a lot of new field definitions
  garmin: teach the parser to show undefined values for unknown fields too
  garmin: fix file length header parsing
  garmin: teach the parser about invalid values and more dates
  garmin: some fields are defined in all message types
  Garmin: start parsing definition records
  Garmin Descent Mk1: flesh out the actual downloading part
  Add Garmin Descent Mk1 skeleton
  Add 'USB storage' transport enumeration
2018-08-31 13:24:03 -07:00
Linus Torvalds
fe2a43e798 Add dc_usb_storage_open to the symbols list
Apparetly the Windows build needs this for the library building.

Reported-by: Wojciech Więckowski <xplwowi@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-31 13:21:56 -07:00
Linus Torvalds
63cd80c560 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream libdivecomputer changes from Jef Driesen.

* https://github.com/libdivecomputer/libdivecomputer:
  Add Travis CI integration
  Fix the transport command-line parameter
  Document dc_descriptor_get_model
  Include stddef.h in iostream.h
  Add support for the Mares Smart Air
  Fix the average depth for older OSTC dives
  Add support for the Oceanic Pro Plus X
2018-08-31 12:52:50 -07:00
Linus Torvalds
22a96bf395 garmin: only record gasmixes for cylinders that aren't enabled
This actually takes the gas status information into account, and doesn't
show gas mixes that are disabled.

All the Garmin Descent data now looks reasonable, but we're not
generating any events (so no warnings, but also no gas change events
etc).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-31 12:25:43 -07:00
Linus Torvalds
6a6e60c9bb garmin: don't emit fake device info and vendor event
The libdivecomputer model is just broken - we don't know this
information before parsing the dive.  But let's not emit a fake event
that generates bogus serial number data.  I thought I'd be able to fill
it in, but this really isn't reasonable, so disable it entirely for now.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-31 09:54:08 -07:00
Linus Torvalds
994efff75a garmin: add support for downloading gas mixes
This clarifies and generalizes the "pending sample data" a bit to also
work for gas mixes, since it's one of those things where you get
multiple fields in random order, and it needs to be batched up into one
"this gas for this cylinder" thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-31 09:44:37 -07:00
Linus Torvalds
6b7c269c9c garmin: add GPS coordinate data and improve parser_get_field() reports
This adds all the GPS information I found, although for dives the
primary ones do seem to be the "session" entry and exit ones.

But I'm exporting all of them as strings, so that we can try to figure
out what they mean.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-29 17:52:07 -07:00
Linus Torvalds
c8e52081cd garmin: actually start using the parsed data
This gets me real profiles, with depth and temperature information.

Sadly, the temperature data seems to be in whole degrees C, which is not
good for diving.  But certainly not unheard of.

Also, while this does actually transfer a lot of other information too,
there are certainly things missing.  No gas information is gathered
(although we do parse it, we just don't save it), and none of the events
are parsed at all.

And the GPS information that we have isn't passed on yet, because there
are no libdivecomputer interfaces to do that.  I'll have to come up with
something.

But it's actually almost useful.  All the basics seem to be there.  How
*buggy* it is, I do not know, but the profiles don't look obviously
broken.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-29 15:55:48 -07:00
Linus Torvalds
00a90e2822 garmin: turn all the remaining unrecognized fields into DEBUG messages
There aren't that many relevant ones left, and I have reached the point
where I think the remaining missing fields just aren't that important
any more.  You can always get them by saving the libdivecomputer
log-file and see the debug messages that way.

Now I'll need to turn the parsing skeleton into actually generating the
actual libdivecomputer data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-29 12:49:56 -07:00
Linus Torvalds
6d470d8430 garmin: add a lot of new field definitions
This actually seems to cover almost all of the relevant dive fields.
There's a lot of different GPS coordinates, I have no idea what they all
are, but they are at least marked in the definitions.

NOTE! None of this actually fills in any information yet.  It's all
about just parsing things and getting the types etc right.

On that note, this also adds a bit of dynamic type checking, which
caught a mistake or two.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-29 12:22:42 -07:00
Linus Torvalds
3dbe5353f5 garmin: teach the parser to show undefined values for unknown fields too
Make it easier to see which of the unknown fields don't contain anything
interesting.

Soon this will be at the stage where the parser skeleton itself doesn't
need much work, and I should look at the actual data and turn it into
samples instead.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-28 17:29:38 -07:00
Linus Torvalds
6d53e31cba garmin: fix file length header parsing
Oops.  I used array_uint16_le() to get the data size.  Too much
copy-and-paste from the profile version (which is indeed 16 bits).

The data size is a 32-bit entity, and this would truncate the data we
read.

Also, verify that there is space for the final CRC in the file, even if
we don't actually check it.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-28 17:26:48 -07:00
Linus Torvalds
bc2ba57302 garmin: teach the parser about invalid values and more dates
The invalid values skip the parser callback function entirely.  Of
course, since it's not really doing anything right now, that's mostly
costmetic.

Extend the FIT type declarations to also have the invalid values.

Also, add a few timestamp entries, and print them out to show the
timestamps in a human-legible format.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-28 16:18:06 -07:00
Linus Torvalds
b65b2318f1 garmin: some fields are defined in all message types
It turns out that the timestamp field can exist across all message
types, as can a few other special fields.

Split those out as "ANY" type fields, so that we get the field
descriptor without having to fill in every message descriptor.

This also makes the message descriptors smaller, since we no longer need
to worry about the high-numbered (253) timestamp field in the arrays.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-28 15:00:54 -07:00
Linus Torvalds
2c7479ad1c Garmin: start parsing definition records
This is _very_ incomplete.  The FIT file is really fairly generic, but
this has the basics for parsing, with tables to look up the low-level
parsers by the FIT "message ID" and "field nr".

It doesn't actually parse anything yet, so consider this a FIT decoder
skeleton.

Right now it basically prints out the different record values, and names
then for the (few) cases where I've found or guessed the numbers.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-28 12:40:16 -07:00
Linus Torvalds
a726a38cbb Garmin Descent Mk1: flesh out the actual downloading part
It's really just reading files from storage, but with the proper sorting
and fingerprint handling.

The Garmin back-end does no actual parsing yet, so the end result is
garbage, but now the data has technically been downloaded.  Without the
parser, I haven't actually verified that any of it is remotely correct,
but it all looks good.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-27 15:10:33 -07:00
Linus Torvalds
8f790b52e4 Add Garmin Descent Mk1 skeleton
This does absolutely nothing, but it adds the basic skeleton for a new
dive computer support.

Not only don't I have any real code for any of this yet, but I actually
think it might be useful to have a "this is how to add a new dive
computer" example commit.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-27 13:19:29 -07:00
Linus Torvalds
8735156e89 Add 'USB storage' transport enumeration
We now have at least two dive computers that enumerate as USB storage
devices: the Uemis Zurich and the Garmin Descent Mk1.

The Uemis is handled purely inside of subsurface, with no
libdivecomputer support.  That was likely a mistake, but it was not
practical to do a libdivecomputer backend for it at the time.

The Garmin Descent Mk1 support would be much nicer to have natively in
libdivecomputer, and looks much more relevant and practical than the
Uemis situation was.

So start off with defining a new transport type.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-08-27 13:17:05 -07:00
Dirk Hohndel
bb985eedbb Mark Aqualung i750TC as Bluetooth capable
There is also an i300C that is Bluetooth capable, but I don't know if
that's the same model as the i300 or a different variation.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-08-05 12:04:30 -07:00
Linus Torvalds
8f4945dc1e Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with misc fixes upstream.

This fixes a couple of small error cases.

* 'master' of git://github.com/libdivecomputer/libdivecomputer:
  Don't pass a NULL pointer to memcpy
  Fix an uninitialized variable
2018-06-28 09:28:27 -07:00
Linus Torvalds
02560a7e7f Merge git://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge with upstream libdivecomputer from Jef.

This fixes some sleeping functions, and also implements support for the
Tecdiving DiveComputer.eu dive computers.

There's also various minor cleanups.  Most notable is perhaps the
unification of the Uwatec dive computer backends.

* git://github.com/libdivecomputer/libdivecomputer:
  Initialize the socket library for the bluetooth discovery
  Fix the length of the Suunto D6i gas change event
  Add support for the Tecdiving DiveComputer.eu
  Fix the Mac OS X timer implementation
  Add the average depth to the xml output
  Skip the handshake for BLE communication
  Unify the Uwatec Smart, Meridian and G2 backends
  Re-organize the packet send/receive code
  Use symbolic constants for the commands
  Implement an rfcomm filter function
  Remove the filter for HW OSTC's without bluetooth
  Implement the sleep function for IrDA and bluetooth
2018-06-27 08:05:00 -07:00
Linus Torvalds
5255ba5448 Merge https://github.com/libdivecomputer/libdivecomputer into Subsurface-NG
Merge upstream updates from Jef Driesen.

This fixes the parsing of the Uwatec Aladin Tec (and Tec 2G) by adding a
missing event descriptor.

* 'master' of https://github.com/libdivecomputer/libdivecomputer:
  Add a missing event descriptor
2018-06-21 07:56:13 +09:00
Anton Lundin
503d934c19 shearwater: Emit a string saying the source of ppo2 values
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-21 07:55:12 +09:00
Anton Lundin
902dbf4d6d shearwater: Fallback to average/voted ppo2
If we can't find any calibration values for the individual sensors,
fallback to emitting the average/voted ppo2 instead, so users always get
a ppo2 value.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-06-21 07:55:12 +09:00
Dirk Hohndel
e0761561e9 Mares: add BLE for dive computers that support bluelink pro
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-12 21:12:35 -07:00
Linus Torvalds
d264349676 Re-instate the lack of handshaking for the Scubapro Aladin Sport Matrix
I thought this wasn't needed any more (incorrectly thinking that Jef had
knowledge we didn't - he had merged the other changes), and had just
taken Jef's version of the code.

Berthold Stöger tells me otherwise.  The Aladin Sport Matrix returns 0
instead of 1 to the initial handshake, and makes libdivecomputer
unhappy.  This just skips the handshake entirely for the Sport Matrix,
since apparently LogTrak doesn't do any either.

See also commit 8a84ece7d0ef ("Support for the Scubapro Aladin Sport
Matrix") in our old Subsurface branch.

Reported-by: Berthold Stöger <berthold.stoeger@tuwien.ac.at>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-25 12:53:48 -07:00
Linus Torvalds
e97a47cca5 Shearwater: add extended information parsing
This adds the string field interface to the Shearwater family of dive
computers.

That includes proper serial number formatting, but it also has a lot of
new fields for battery information (both the dive computer itself and
the transmitter) but also deco model information.

Much of the deco model cases come from Anton Lundin in the original
subsurface branch, and Dirk Hohndel added the battery type and serial
number and firmware version data.  And I ended up massaging it even in
that original branch, so it blamed me for all these lines even back
there.

The sign-offs from Dirk and Anton are from the original commits.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
14490a462a Suunto EON Steel/Core: add extended information parsing
This adds the string field interface to the Suunto EON Steel and EON
Core.

This is actually a big deal, because it gets rid of all the ad-hoc
string parsing, and actually just uses the strings that the EON Steel
events and warnings natively use.

It also reports the severity of the notification/warning/alarm, so that
Subsurface can then use the proper icon.  An event isn't just an event,
there's a big difference between a warning and just a notification.

It also fills in the tank information data for closed-circuit cylinder
use.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Dirk Hohndel
97c8bb908e Suunto D9 family: add extended information parsing
This adds the string field interface to the Suunto D9 family.

It's really just the proper serial number handling.  From Dirk's
original commit:

 "We have the correct firmware in the devinfo, but that's the firmware
  the dive computer is on NOW, not necessarily the firmware it was using
  when recording the dive"

so thus just serial number.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Dirk Hohndel
f248a95d64 Oceanic Atom2: add extended string information parsing
This adds the string field interface to the Oceanic Atom2 family,
including the proper serial number handling.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Dirk Hohndel
df1e97c471 Heinrichs Weikamp OSTC: add extended information parsing
This adds the string field interface to the HW OSTC family, including
the proper serial number handling.

The deco model information was done by Anton Lundin in the original
subsurface branch, and the salinity, serial number, battery voltage and
desat information was added by Dirk Hohndel.  Jan Mulder added the
battery percentage.

[ The sign-offs have been taken from the original commits in that old
  subsurface branch, and I'm marking Dirk as the main author because on
  the whole most of the lines come from him  - Linus ]

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
a38d640df4 Make dc_parser_new() pass in the serial number to +dc_parser_new_internal
The libdivecomputer serial number handling is very very messy.

There are multiple issues that make it messy:

 - it's not actually figured out at parse-time, it's figured out at
   download time and passed up through the DC_EVENT_DEVINFO as part of
   the devinfo structure.

 - it's passed around as an "unsigned in" in the devinfo structure,
   which is entirely useless to anybody but libdivecomputer, since a
   serial number isn't actually a number, but a string, and the format
   of the string depends on the dive computer.

 - it is *not* passed to the parser, so the parser can't do a better job
   at it later.

But it turns out that the sane "create new parser" helper function does
actually get it, as part of the "devinfo" that is passed to it.  So as
long as you use that sane interface, we can now pass it in to the actual
parser creation, and then the dive computer parsers that want to do a
reasonable job of actually generating a real serial number string can
now save it off and do so.

This just adds the infrastructure to make this possible.  I'll do the
dive computers one by one.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
6c51ace384 Shearwater Petrel: make the hardware ID decoding a bit easier to read
Dirk seems to have some documentation about the different ID's, plus it
just makes sense to order the switch statement by number.

This is partly based on Dirk's original commit to do the different model
numbers, with various changes over time due to merge conflict
resolution.  Dirk's sign-off comes from Dirks commit in the original
subsurface branch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Dirk Hohndel
db08a534bf Atomics Cobalt: use the new DC string fields
Not a lot of fields, but give the serial number in the proper format,
and other version information (Software version and bootloader version).
And the Nofly time that the dive computer reports.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
167848aa59 Add subsurface-specific cylinder descriptor extension
This extends the libdivecomputer notion of "dc_tankvolume_t" to not just
have the tank volume type (imperial or metric), but be a "dc_tankinfo_t"
that shows other information about the cylinder.

The imperial-vs-metric data remains the same two values:

 1 - metric
 2 - imperial

but instead of being an enumeration of volume types, it is extended to a
bitmap of tank information, and the other bits currently are

 4 - CC diluent cylinder
 8 - CC O2 cylinder

with possible future extensions (bailout gas, perhaps).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
362fe3f936 Add subsurface-specific DC field extension: descriptor/value strings
The default libdivecomputer fields are good for structured data that has
a well-defined format, like the cylinder information, or the temperature
data.

But it is entirely useless for miscellaneous divecomputer-specific
information, where there is no standard way of representing the data
across different kinds of dive computers.

Examples of this include simple things like deco calculation algorithm
(what kind of Buehlmann, gradient factor information or is it some
vendor-specific mode?) and even something as trivial as a serial number.

No, serial numbers aren't numbers. They are strings. Really.

But this also includes much more complex data that is really specific to
a particular dive computer or family: what the battery status is for the
dive computer or the wireless transmitters it is connected to (sometimes
it's a voltage, sometimes it's a percentage, sometimes it's just "good"
or "marginal").

It also includes random incidental information like firmware version
numbers (again, these are strings, not numbers, despite the name) or
dive mode and personal adjustment information.

So allow the dive computer to just give "extra information" in the form
of an array of { key, value } string pairs.  For my Perdix AI the
information could be

  { "Serial", "370d1f24" }
  { "FW Version", "44" }
  { "Deco model", "GF 40/85" }
  { "Battery type", "3.6V Saft" }
  { "Battery at end", "3.4 V" }

and for my EON Steel with three wireless transmitters connected it can
look like this:

  { "Serial", "1742104730" }
  { "FW Version", "1.6.5" }
  { "HW Version", "70.3.0" }
  { "Battery at start", "Charge: 83%, Voltage: 4.012V" }
  { "Deco algorithm", "Suunto Fused RGBM" }
  { "Personal Adjustment", "P-2" }
  { "Battery at end", "Charge: 79%, Voltage: 3.977V" }
  { "Dive Mode", "Trimix" }
  { "Desaturation Time", "7:53" }
  { "Transmitter ID", "1519107801" }
  { "Transmitter Battery at start", "87 %" }
  { "Transmitter Battery at end", "87 %" }
  { "Transmitter ID", "1550110028" }
  { "Transmitter Battery at start", "100 %" }
  { "Transmitter Battery at end", "100 %" }
  { "Transmitter ID", "1719102387" }
  { "Transmitter Battery at start", "100 %" }
  { "Transmitter Battery at end", "100 %" }

so this data is inherently unstructured and dependent on the dive
computer, but quite relevant to the diver.  Subsurface shows this in the
"Extra Info" panel for each dive computer.

Also teach the example output-xml code about the new string field
extension.  That example output-xml code was written by Anton Lundin in
the old Subsurface branch, and signed-off-by Dirk.  The sign-offs here
are taken from that original work.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
49f89d2205 Add subsurface-specific event extension: event strings and severity
We _really_ find the standard libdivecomputer event enumeration much too
inflexible and not giving us enough useful information.  This is
particularly noticeable with the Suunto EON Steel/Core, where there are
no fixed event enumerations, but instead the dive computer literally
gives you event strings.

Do the same thing in the libdivecomputer interface: allow an event of
type SAMPLE_EVENT_STRING which instead of the useless "value" gives an
actual string describing the event.

Also, extend the "flags" field to have not just a NONE/BEGIN/END marker,
but a severity level. The severity level is 3 bits, so 0-7, with the meaning being

 0 - 'no severity info'
 1 - state change (so 'surface' event or similar - don't even show it by default)
 2 - notification (informational, eg "safety stop", "tank change")
 3 - warning ("ascent speed")
 4 - alarm (some actual dive violation).
 5-7: future expansion?

Think of 0 as "legacy - missing information", 1 as "internal DC thing",
and 2-4 as (green-yellow-red).

This makes it possible for the dive computer back-end to give the user
actual useful information for events.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
Linus Torvalds
063041ddca Add subsurface-specific build setup
This changes the dc_version_suffix to show that this is the subsurface
'next generation' branch, and does minor tweaks to the build system: we
add the 'build' subdirectory to the .gitignore branch because that's
where we typically do our builds, and we tweak the default compiler
warning flags to not be as annoying.

No real semantic changes.

This is partially based off patches in the original Subsurface-branch by
Dirk Hohndel (configure.ac) and Jan Mulder (gitignore).  The sign-offs
for those come from those patches:

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-04-24 17:32:21 -07:00
237 changed files with 5353 additions and 20768 deletions

View File

@ -1,173 +0,0 @@
name: Build
on: [push, pull_request]
jobs:
linux:
name: Linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
- run: autoreconf --install --force
- run: ./configure --prefix=/usr
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
mac:
name: Mac
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
compiler: [gcc, clang]
env:
CC: ${{ matrix.compiler }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: brew install autoconf automake libtool hidapi libusb
- run: autoreconf --install --force
- run: ./configure --prefix=/usr
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.compiler }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}-${{ matrix.compiler }}
path: ${{ github.job }}-${{ matrix.compiler }}.tar.gz
windows:
name: Windows
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
arch: [i686, x86_64]
steps:
- uses: actions/checkout@v3
- name: Install dependencies
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
- name: Install libusb
env:
LIBUSB_VERSION: 1.0.26
run: |
wget -c https://github.com/libusb/libusb/archive/refs/tags/v${LIBUSB_VERSION}.tar.gz
tar xzf v${LIBUSB_VERSION}.tar.gz
pushd libusb-${LIBUSB_VERSION}
autoreconf --install --force
./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
make
make install DESTDIR=$PWD/../artifacts
popd
- name: Install hidapi
env:
HIDAPI_VERSION: 0.12.0
run: |
wget -c https://github.com/libusb/hidapi/archive/refs/tags/hidapi-${HIDAPI_VERSION}.tar.gz
tar xzf hidapi-${HIDAPI_VERSION}.tar.gz
pushd hidapi-hidapi-${HIDAPI_VERSION}
autoreconf --install --force
./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr LDFLAGS='-static-libgcc'
make
make install DESTDIR=$PWD/../artifacts
popd
- run: autoreconf --install --force
- run: ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr
env:
PKG_CONFIG_LIBDIR: ${{ github.workspace }}/artifacts/usr/lib/pkgconfig
PKG_CONFIG_SYSROOT_DIR: ${{ github.workspace }}/artifacts
PKG_CONFIG_ALLOW_SYSTEM_CFLAGS: 1
PKG_CONFIG_ALLOW_SYSTEM_LIBS: 1
- run: make
- run: make distcheck
- name: Package artifacts
run: |
make install DESTDIR=$PWD/artifacts
tar -czf ${{ github.job }}-${{ matrix.arch }}.tar.gz -C artifacts usr
- uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}-${{ matrix.arch }}
path: ${{ github.job }}-${{ matrix.arch }}.tar.gz
# msvc:
#
# name: Visual Studio
#
# runs-on: windows-latest
#
# strategy:
# fail-fast: false
# matrix:
# platform: [x86, x64]
#
# env:
# CONFIGURATION: Release
#
# steps:
# - uses: actions/checkout@v3
# - uses: msys2/setup-msys2@v2
# with:
# install: autoconf automake libtool pkg-config make gcc
# - run: |
# autoreconf --install --force
# ./configure --prefix=/usr
# make -C src revision.h
# shell: msys2 {0}
# - uses: microsoft/setup-msbuild@v1
# - run: msbuild -m -p:Platform=${{ matrix.platform }} -p:Configuration=${{ env.CONFIGURATION }} contrib/msvc/libdivecomputer.vcxproj
# - uses: actions/upload-artifact@v3
# with:
# name: ${{ github.job }}-${{ matrix.platform }}
# path: contrib/msvc/${{ matrix.platform }}/${{ env.CONFIGURATION }}/bin
android:
name: Android
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: |
autoreconf --install --force
./configure --prefix=/usr
make -C src revision.h
- run: $ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
- uses: actions/upload-artifact@v3
with:
name: ${{ github.job }}
path: contrib/android/libs

View File

@ -1,47 +0,0 @@
name: Release
on:
push:
tags: 'v*'
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Version number
id: version
run: |
VERSION="${GITHUB_REF/refs\/tags\/v/}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
- name: Build distribution tarball
id: build
run: |
sudo apt-get install libbluetooth-dev libusb-1.0-0-dev
autoreconf --install --force
./configure
make
make distcheck
- name: Check tarball version number
id: check
run: |
FILENAME="libdivecomputer-${{ steps.version.outputs.version }}.tar.gz"
if [ ! -f "${FILENAME}" ]; then
echo ::error ::Tarball \'${FILENAME}\' not found!
exit 1
fi
- name: Create Github release
id: release
run: |
VERSION="${{ steps.version.outputs.version }}"
if [ "${VERSION}" != "${VERSION%%-*}" ]; then
PRERELEASE="-p"
fi
gh release create ${PRERELEASE} "${{ github.ref }}" "libdivecomputer-${VERSION}.tar.gz"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

31
.gitignore vendored
View File

@ -37,7 +37,33 @@ Makefile.in
/doc/html/ /doc/html/
/doc/latex/ /doc/latex/
/examples/aladin
/examples/atom2
/examples/d9
/examples/darwin
/examples/dctool /examples/dctool
/examples/edy
/examples/eon
/examples/frog
/examples/iconhd
/examples/leonardo
/examples/memomouse
/examples/n2ition3
/examples/nemo
/examples/ostc
/examples/ostc-fwupdate
/examples/predator
/examples/puck
/examples/sensus
/examples/sensuspro
/examples/sensusultra
/examples/smart
/examples/solution
/examples/universal
/examples/veo250
/examples/vtpro
/examples/vyper
/examples/vyper2
/include/libdivecomputer/version.h /include/libdivecomputer/version.h
@ -47,10 +73,11 @@ Makefile.in
/m4/ltsugar.m4 /m4/ltsugar.m4
/m4/ltversion.m4 /m4/ltversion.m4
/msvc/x64/ /msvc/Debug/
/msvc/x86/ /msvc/Release/
/msvc/*.ncb /msvc/*.ncb
/msvc/*.suo /msvc/*.suo
/msvc/*.vcproj.*.user
/src/libdivecomputer.exp /src/libdivecomputer.exp
/src/libdivecomputer.la /src/libdivecomputer.la

View File

@ -16,8 +16,4 @@ pkgconfig_DATA = libdivecomputer.pc
EXTRA_DIST = \ EXTRA_DIST = \
libdivecomputer.pc.in \ libdivecomputer.pc.in \
contrib/README \ msvc/libdivecomputer.vcproj
contrib/android/Android.mk \
contrib/msvc/libdivecomputer.vcxproj \
contrib/msvc/libdivecomputer.vcxproj.filters \
contrib/udev/libdivecomputer.rules

74
NEWS
View File

@ -1,77 +1,3 @@
Version 0.8.0 (2023-05-11)
==========================
The v0.8.0 release is mainly a bugfix release, and brings in support for a
number of new devices. This release is fully backwards compatible with the
previous one.
New features:
* Add support for new backends:
- excursion: Deep Six Excursion, Crest CR-4, Genesis Centauri, Tusa TC1, Scorpena Alpha
- screen: Seac Screen and Action
- cosmiq: Deepblu Cosmiq+
- s1: Oceans S1
- freedom: Divesoft Freedom and Liberty
* Add support for some new devices:
- Aqualung: i200C
- Cressi: Donatello, Michelangelo, Neon
- Mares: Puck Pro +
- Oceanic: Geo Air
- Ratio: iX3M 2
- Scubapro: G2 TEK
- Shearwater: Petrel 3, Perdix 2
- Sherwood: Amphos Air 2.0
* Add support for parsing the decompression model
* Add a public api to configure the depth calibration
* Add a public api to configure the clock synchronization
* Add a basic Android build system
Removed/changed features:
* Migrate to Visual Studio 2013 (or newer)
* Move the Visual Studio project to the contrib directory
Version 0.7.0 (2021-05-07)
==========================
The main highlight of the v0.7.0 release is the introduction of the new
I/O interface. With this common interface, the dive computer backends
can more easily use different I/O implementations at runtime, including
an application defined one. This is needed to support Bluetooth Low
Energy (BLE), for which there is no built-in implementation available.
Due to the fundamental changes to the I/O layer, this release is not
backwards compatible.
New features:
* A new I/O interface
* Add support for new backends:
- goa: Cressi Goa and Cartesio
- divecomputereu: Tecdiving DiveComputer.eu
- extreme: McLean Extreme
- lynx: Liquivision Xen, Xeo, Lynx and Kaon
- sp2: Sporasub SP2
* Add support for many new devices:
- Aqualung: i100, i200C, i300C, i470TC, i550C, i770R
- Heinrichs Weikamp: OSTC 2 TR
- Mares: Genius, Horizon, Quad Air, Smart Air
- Oceanic: Geo 4.0, Pro Plus 4, Pro Plus X, Veo 4.0
- Ratio: iDive Color, iX3M GPS, iX3M 2021
- Scubapro: A1, A2, Aladin H Matrix, G2 Console, G2 HUD
- Seac: Guru, Jack
- Shearwater: Peregrine, Teric
- Sherwood: Amphos 2.0, Beacon, Sage, Wisdom 4
- Suunto: D5, EON Steel Black
- Tusa: Talis
* Firmware upgrade support for the Ratio computers
* Support for semi-closed circuit diving
Removed/changed features:
* Unify the Uwatec Smart, Meridian and G2 backends
Version 0.6.0 (2017-11-24) Version 0.6.0 (2017-11-24)
========================== ==========================

View File

@ -1,6 +1,6 @@
# Versioning. # Versioning.
m4_define([dc_version_major],[0]) m4_define([dc_version_major],[0])
m4_define([dc_version_minor],[9]) m4_define([dc_version_minor],[7])
m4_define([dc_version_micro],[0]) m4_define([dc_version_micro],[0])
m4_define([dc_version_suffix],[devel-Subsurface-NG]) m4_define([dc_version_suffix],[devel-Subsurface-NG])
m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix])) m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix]))
@ -72,21 +72,18 @@ AM_CONDITIONAL([HAVE_MANDOC],[test -n "$MANDOC"])
# Enable automake silent build rules. # Enable automake silent build rules.
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
# Checks for operating system. # Checks for native Windows.
AC_MSG_CHECKING([for operating system]) AC_MSG_CHECKING([for native Win32])
case "$host" in case "$host" in
*-*-mingw*) *-*-mingw*)
platform=windows os_win32=yes
;;
*-*-darwin*)
platform=mac
;; ;;
*) *)
platform=default os_win32=no
;; ;;
esac esac
AC_MSG_RESULT([$platform]) AC_MSG_RESULT([$os_win32])
AM_CONDITIONAL([OS_WIN32], [test "$platform" = "windows"]) AM_CONDITIONAL([OS_WIN32], [test "$os_win32" = "yes"])
DEPENDENCIES="" DEPENDENCIES=""
@ -103,29 +100,16 @@ AS_IF([test "x$with_libusb" != "xno"], [
]) ])
]) ])
# Checks for MTP support.
AC_ARG_WITH([libmtp],
[AS_HELP_STRING([--without-libmtp],
[Build without the libmtp library])],
[], [with_libmtp=auto])
AS_IF([test "x$with_libmtp" != "xno"], [
PKG_CHECK_MODULES([LIBMTP], [libmtp], [have_libmtp=yes], [have_libmtp=no])
AS_IF([test "x$have_libmtp" = "xyes"], [
AC_DEFINE([HAVE_LIBMTP], [1], [libmtp library])
DEPENDENCIES="$DEPENDENCIES libmtp"
])
])
# Checks for HIDAPI support. # Checks for HIDAPI support.
AC_ARG_WITH([hidapi], AC_ARG_WITH([hidapi],
[AS_HELP_STRING([--without-hidapi], [AS_HELP_STRING([--without-hidapi],
[Build without the hidapi library])], [Build without the hidapi library])],
[], [with_hidapi=hidapi]) [], [with_hidapi=auto])
AS_IF([test "x$with_hidapi" != "xno"], [ AS_IF([test "x$with_hidapi" != "xno"], [
PKG_CHECK_MODULES([HIDAPI], [$with_hidapi], [have_hidapi=yes], [have_hidapi=no]) PKG_CHECK_MODULES([HIDAPI], [hidapi], [have_hidapi=yes], [have_hidapi=no])
AS_IF([test "x$have_hidapi" = "xyes"], [ AS_IF([test "x$have_hidapi" = "xyes"], [
AC_DEFINE([HAVE_HIDAPI], [1], [hidapi library]) AC_DEFINE([HAVE_HIDAPI], [1], [hidapi library])
DEPENDENCIES="$DEPENDENCIES $with_hidapi" DEPENDENCIES="$DEPENDENCIES hidapi"
]) ])
]) ])
@ -170,7 +154,7 @@ AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], , , [
# Checks for header files. # Checks for header files.
AC_CHECK_HEADERS([linux/serial.h]) AC_CHECK_HEADERS([linux/serial.h])
AC_CHECK_HEADERS([IOKit/serial/ioss.h]) AC_CHECK_HEADERS([IOKit/serial/ioss.h])
AC_CHECK_HEADERS([unistd.h getopt.h]) AC_CHECK_HEADERS([getopt.h])
AC_CHECK_HEADERS([sys/param.h]) AC_CHECK_HEADERS([sys/param.h])
AC_CHECK_HEADERS([pthread.h]) AC_CHECK_HEADERS([pthread.h])
AC_CHECK_HEADERS([mach/mach_time.h]) AC_CHECK_HEADERS([mach/mach_time.h])
@ -190,7 +174,6 @@ AC_CHECK_FUNCS([clock_gettime mach_absolute_time])
AC_CHECK_FUNCS([getopt_long]) AC_CHECK_FUNCS([getopt_long])
# Checks for supported compiler options. # Checks for supported compiler options.
AX_APPEND_COMPILE_FLAGS([-Werror=unknown-warning-option],[ERROR_CFLAGS])
AX_APPEND_COMPILE_FLAGS([ \ AX_APPEND_COMPILE_FLAGS([ \
-Wall \ -Wall \
-Wshadow \ -Wshadow \
@ -207,13 +190,11 @@ AX_APPEND_COMPILE_FLAGS([ \
-Wno-unused-but-set-variable \ -Wno-unused-but-set-variable \
-Wno-pointer-sign \ -Wno-pointer-sign \
-Wno-shadow \ -Wno-shadow \
-Wenum-conversion \
-Werror=enum-conversion \
-fmacro-prefix-map='$(top_srcdir)/'= \ -fmacro-prefix-map='$(top_srcdir)/'= \
],,[$ERROR_CFLAGS]) ])
# Windows specific compiler options. # Windows specific compiler options.
AS_IF([test "$platform" = "windows"], [ AS_IF([test "$os_win32" = "yes"], [
AX_APPEND_COMPILE_FLAGS([-Wno-pedantic-ms-format]) AX_APPEND_COMPILE_FLAGS([-Wno-pedantic-ms-format])
]) ])
@ -229,25 +210,6 @@ m4_ifset([dc_version_suffix],[
AC_DEFINE(HAVE_VERSION_SUFFIX, [1], [Define if a version suffix is present.]) AC_DEFINE(HAVE_VERSION_SUFFIX, [1], [Define if a version suffix is present.])
]) ])
# Supported transports
transport_serial="yes"
transport_usb="${have_libusb-no}"
if test "$have_hidapi" = "yes"; then
transport_usbhid="yes"
elif test "$have_libusb" = "yes" && test "$platform" != "mac"; then
transport_usbhid="yes"
else
transport_usbhid="no"
fi
if test "$platform" = "windows"; then
transport_irda="$ac_cv_header_af_irda_h"
transport_bluetooth="$ac_cv_header_ws2bth_h"
else
transport_irda="$ac_cv_header_linux_irda_h"
transport_bluetooth="${have_bluez-no}"
fi
transport_ble="no"
AC_CONFIG_FILES([ AC_CONFIG_FILES([
libdivecomputer.pc libdivecomputer.pc
Makefile Makefile
@ -255,41 +217,10 @@ AC_CONFIG_FILES([
include/libdivecomputer/Makefile include/libdivecomputer/Makefile
include/libdivecomputer/version.h include/libdivecomputer/version.h
src/Makefile src/Makefile
src/libdivecomputer.rc
doc/Makefile doc/Makefile
doc/doxygen.cfg doc/doxygen.cfg
doc/man/Makefile doc/man/Makefile
examples/Makefile examples/Makefile
]) ])
AC_OUTPUT AC_OUTPUT
AC_MSG_NOTICE([
$PACKAGE $VERSION
===============
Compiler:
CC : $CC
CFLAGS : $CFLAGS
LDFLAGS : $LDFLAGS
Features:
Logging : $enable_logging
Pseudo terminal : $enable_pty
Example applications : $enable_examples
Documentation : $enable_doc
Transports:
Serial : $transport_serial
USB : $transport_usb
USBHID : $transport_usbhid
IrDA : $transport_irda
Bluetooth : $transport_bluetooth
BLE : $transport_ble
Building:
Type 'make' to compile $PACKAGE.
Type 'make install' to install $PACKAGE.
])

View File

@ -1,56 +0,0 @@
Alternative build systems
=========================
The autotools based build system is the official build system for the
libdivecomputer project. But for convenience, a few alternative build systems
are available as well. Unfortunately, these builds systems require a few extra
steps to generate some header files.
If you have access to a UNIX build system (for example a Linux virtual machine,
MinGW, Cygwin or the Windows Subsystem for Linux), you can use the autotools
build system to generate those files:
$ autoreconf --install --force
$ ./configure
$ make -C src revision.h
Alternative, you can generate those files manually. First, create the version.h
file from the version.h.in template:
$ cp include/libdivecomputer/version.h.in include/libdivecomputer/version.h
and replace all the @DC_VERSION@ placeholders with the values defined in the
configure.ac file.
Next, generate the revision.h file:
$ echo "#define DC_VERSION_REVISION \"$(git rev-parse --verify HEAD)\"" > src/revision.h
The alternative build systems are ready to use now.
Visual Studio
-------------
The Visual Studio project file can be opened in the IDE, or build directly from
the command-line:
msbuild -m -p:Platform=x86|x64 -p:Configuration=Debug|Release contrib/msvc/libdivecomputer.vcxproj
Android NDK
-----------
$ANDROID_NDK/ndk-build -C contrib/android NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
Linux udev rules
================
For dive computers using USB or USB HID communication, regular users typically
don't have the necessary permissions to access the device nodes. This can be
fixed with some udev rules.
Install the udev rules, and reload them:
$ sudo cp contrib/udev/libdivecomputer.rules /etc/udev/rules.d/
$ sudo udevadm control --reload
Note: the provided udev rules assume the user is in the plugdev group.

View File

@ -1,148 +0,0 @@
LOCAL_PATH := $(call my-dir)/../..
include $(CLEAR_VARS)
LOCAL_MODULE := libdivecomputer
LOCAL_CFLAGS := -DENABLE_LOGGING -DHAVE_VERSION_SUFFIX -DHAVE_PTHREAD_H -DHAVE_STRERROR_R -DHAVE_CLOCK_GETTIME -DHAVE_LOCALTIME_R -DHAVE_GMTIME_R -DHAVE_TIMEGM -DHAVE_STRUCT_TM_TM_GMTOFF
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
src/aes.c \
src/array.c \
src/atomics_cobalt.c \
src/atomics_cobalt_parser.c \
src/bluetooth.c \
src/buffer.c \
src/checksum.c \
src/citizen_aqualand.c \
src/citizen_aqualand_parser.c \
src/cochran_commander.c \
src/cochran_commander_parser.c \
src/common.c \
src/context.c \
src/cressi_edy.c \
src/cressi_edy_parser.c \
src/cressi_goa.c \
src/cressi_goa_parser.c \
src/cressi_leonardo.c \
src/cressi_leonardo_parser.c \
src/custom.c \
src/datetime.c \
src/deepblu_cosmiq.c \
src/deepblu_cosmiq_parser.c \
src/deepsix_excursion.c \
src/deepsix_excursion_parser.c \
src/descriptor.c \
src/device.c \
src/diverite_nitekq.c \
src/diverite_nitekq_parser.c \
src/divesoft_freedom.c \
src/divesoft_freedom_parser.c \
src/divesystem_idive.c \
src/divesystem_idive_parser.c \
src/hdlc.c \
src/hw_frog.c \
src/hw_ostc3.c \
src/hw_ostc.c \
src/hw_ostc_parser.c \
src/ihex.c \
src/iostream.c \
src/irda.c \
src/iterator.c \
src/liquivision_lynx.c \
src/liquivision_lynx_parser.c \
src/mares_common.c \
src/mares_darwin.c \
src/mares_darwin_parser.c \
src/mares_iconhd.c \
src/mares_iconhd_parser.c \
src/mares_nemo.c \
src/mares_nemo_parser.c \
src/mares_puck.c \
src/mclean_extreme.c \
src/mclean_extreme_parser.c \
src/oceanic_atom2.c \
src/oceanic_atom2_parser.c \
src/oceanic_common.c \
src/oceanic_veo250.c \
src/oceanic_veo250_parser.c \
src/oceanic_vtpro.c \
src/oceanic_vtpro_parser.c \
src/oceans_s1.c \
src/oceans_s1_common.c \
src/oceans_s1_parser.c \
src/packet.c \
src/parser.c \
src/pelagic_i330r.c \
src/platform.c \
src/rbstream.c \
src/reefnet_sensus.c \
src/reefnet_sensus_parser.c \
src/reefnet_sensuspro.c \
src/reefnet_sensuspro_parser.c \
src/reefnet_sensusultra.c \
src/reefnet_sensusultra_parser.c \
src/ringbuffer.c \
src/seac_screen.c \
src/seac_screen_parser.c \
src/serial_posix.c \
src/shearwater_common.c \
src/shearwater_petrel.c \
src/shearwater_predator.c \
src/shearwater_predator_parser.c \
src/socket.c \
src/sporasub_sp2.c \
src/sporasub_sp2_parser.c \
src/suunto_common2.c \
src/suunto_common.c \
src/suunto_d9.c \
src/suunto_d9_parser.c \
src/suunto_eon.c \
src/suunto_eon_parser.c \
src/suunto_eonsteel.c \
src/suunto_eonsteel_parser.c \
src/suunto_solution.c \
src/suunto_solution_parser.c \
src/suunto_vyper2.c \
src/suunto_vyper.c \
src/suunto_vyper_parser.c \
src/tecdiving_divecomputereu.c \
src/tecdiving_divecomputereu_parser.c \
src/timer.c \
src/usb.c \
src/usbhid.c \
src/uwatec_aladin.c \
src/uwatec_memomouse.c \
src/uwatec_memomouse_parser.c \
src/uwatec_smart.c \
src/uwatec_smart_parser.c \
src/version.c \
src/zeagle_n2ition3.c \
src/field-cache.c \
src/usb_storage.c \
src/garmin.c \
src/garmin_parser.c
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := dctool
LOCAL_SHARED_LIBRARIES := libdivecomputer
LOCAL_CFLAGS := -DHAVE_UNISTD_H -DHAVE_GETOPT_H -DHAVE_GETOPT_LONG -DHAVE_DECL_OPTRESET=1
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_SRC_FILES := \
examples/common.c \
examples/dctool.c \
examples/dctool_download.c \
examples/dctool_dump.c \
examples/dctool_fwupdate.c \
examples/dctool_help.c \
examples/dctool_list.c \
examples/dctool_parse.c \
examples/dctool_read.c \
examples/dctool_scan.c \
examples/dctool_timesync.c \
examples/dctool_version.c \
examples/dctool_write.c \
examples/output.c \
examples/output_raw.c \
examples/output_xml.c \
examples/utils.c
include $(BUILD_EXECUTABLE)

View File

@ -1,408 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{CEA7215A-D6B5-4840-8086-3C854F371997}</ProjectGuid>
<RootNamespace>libdivecomputer</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\bin\</OutDir>
<IntDir>$(PlatformTarget)\$(Configuration)\obj\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\bin\</OutDir>
<IntDir>$(PlatformTarget)\$(Configuration)\obj\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\bin\</OutDir>
<IntDir>$(PlatformTarget)\$(Configuration)\obj\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(PlatformTarget)\$(Configuration)\bin\</OutDir>
<IntDir>$(PlatformTarget)\$(Configuration)\obj\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_VERSION_SUFFIX;HAVE_AF_IRDA_H;HAVE_WS2BTH_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(OutDir)libdivecomputer.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_VERSION_SUFFIX;HAVE_AF_IRDA_H;HAVE_WS2BTH_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(OutDir)libdivecomputer.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_VERSION_SUFFIX;HAVE_AF_IRDA_H;HAVE_WS2BTH_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader />
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(OutDir)libdivecomputer.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_VERSION_SUFFIX;HAVE_AF_IRDA_H;HAVE_WS2BTH_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<AdditionalDependencies>ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(OutDir)libdivecomputer.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
<ResourceCompile>
<AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\aes.c" />
<ClCompile Include="..\..\src\array.c" />
<ClCompile Include="..\..\src\atomics_cobalt.c" />
<ClCompile Include="..\..\src\atomics_cobalt_parser.c" />
<ClCompile Include="..\..\src\bluetooth.c" />
<ClCompile Include="..\..\src\buffer.c" />
<ClCompile Include="..\..\src\checksum.c" />
<ClCompile Include="..\..\src\citizen_aqualand.c" />
<ClCompile Include="..\..\src\citizen_aqualand_parser.c" />
<ClCompile Include="..\..\src\cochran_commander.c" />
<ClCompile Include="..\..\src\cochran_commander_parser.c" />
<ClCompile Include="..\..\src\common.c" />
<ClCompile Include="..\..\src\context.c" />
<ClCompile Include="..\..\src\cressi_edy.c" />
<ClCompile Include="..\..\src\cressi_edy_parser.c" />
<ClCompile Include="..\..\src\cressi_goa.c" />
<ClCompile Include="..\..\src\cressi_goa_parser.c" />
<ClCompile Include="..\..\src\cressi_leonardo.c" />
<ClCompile Include="..\..\src\cressi_leonardo_parser.c" />
<ClCompile Include="..\..\src\custom.c" />
<ClCompile Include="..\..\src\datetime.c" />
<ClCompile Include="..\..\src\deepblu_cosmiq.c" />
<ClCompile Include="..\..\src\deepblu_cosmiq_parser.c" />
<ClCompile Include="..\..\src\deepsix_excursion.c" />
<ClCompile Include="..\..\src\deepsix_excursion_parser.c" />
<ClCompile Include="..\..\src\descriptor.c" />
<ClCompile Include="..\..\src\device.c" />
<ClCompile Include="..\..\src\diverite_nitekq.c" />
<ClCompile Include="..\..\src\diverite_nitekq_parser.c" />
<ClCompile Include="..\..\src\divesoft_freedom.c" />
<ClCompile Include="..\..\src\divesoft_freedom_parser.c" />
<ClCompile Include="..\..\src\divesystem_idive.c" />
<ClCompile Include="..\..\src\divesystem_idive_parser.c" />
<ClCompile Include="..\..\src\hdlc.c" />
<ClCompile Include="..\..\src\hw_frog.c" />
<ClCompile Include="..\..\src\hw_ostc.c" />
<ClCompile Include="..\..\src\hw_ostc3.c" />
<ClCompile Include="..\..\src\hw_ostc_parser.c" />
<ClCompile Include="..\..\src\ihex.c" />
<ClCompile Include="..\..\src\iostream.c" />
<ClCompile Include="..\..\src\irda.c" />
<ClCompile Include="..\..\src\iterator.c" />
<ClCompile Include="..\..\src\liquivision_lynx.c" />
<ClCompile Include="..\..\src\liquivision_lynx_parser.c" />
<ClCompile Include="..\..\src\mares_common.c" />
<ClCompile Include="..\..\src\mares_darwin.c" />
<ClCompile Include="..\..\src\mares_darwin_parser.c" />
<ClCompile Include="..\..\src\mares_iconhd.c" />
<ClCompile Include="..\..\src\mares_iconhd_parser.c" />
<ClCompile Include="..\..\src\mares_nemo.c" />
<ClCompile Include="..\..\src\mares_nemo_parser.c" />
<ClCompile Include="..\..\src\mares_puck.c" />
<ClCompile Include="..\..\src\mclean_extreme.c" />
<ClCompile Include="..\..\src\mclean_extreme_parser.c" />
<ClCompile Include="..\..\src\oceanic_atom2.c" />
<ClCompile Include="..\..\src\oceanic_atom2_parser.c" />
<ClCompile Include="..\..\src\oceanic_common.c" />
<ClCompile Include="..\..\src\oceanic_veo250.c" />
<ClCompile Include="..\..\src\oceanic_veo250_parser.c" />
<ClCompile Include="..\..\src\oceanic_vtpro.c" />
<ClCompile Include="..\..\src\oceanic_vtpro_parser.c" />
<ClCompile Include="..\..\src\oceans_s1.c" />
<ClCompile Include="..\..\src\oceans_s1_common.c" />
<ClCompile Include="..\..\src\oceans_s1_parser.c" />
<ClCompile Include="..\..\src\packet.c" />
<ClCompile Include="..\..\src\parser.c" />
<ClCompile Include="..\..\src\pelagic_i330r.c" />
<ClCompile Include="..\..\src\platform.c" />
<ClCompile Include="..\..\src\rbstream.c" />
<ClCompile Include="..\..\src\reefnet_sensus.c" />
<ClCompile Include="..\..\src\reefnet_sensuspro.c" />
<ClCompile Include="..\..\src\reefnet_sensuspro_parser.c" />
<ClCompile Include="..\..\src\reefnet_sensusultra.c" />
<ClCompile Include="..\..\src\reefnet_sensusultra_parser.c" />
<ClCompile Include="..\..\src\reefnet_sensus_parser.c" />
<ClCompile Include="..\..\src\ringbuffer.c" />
<ClCompile Include="..\..\src\seac_screen.c" />
<ClCompile Include="..\..\src\seac_screen_parser.c" />
<ClCompile Include="..\..\src\serial_win32.c" />
<ClCompile Include="..\..\src\shearwater_common.c" />
<ClCompile Include="..\..\src\shearwater_petrel.c" />
<ClCompile Include="..\..\src\shearwater_predator.c" />
<ClCompile Include="..\..\src\shearwater_predator_parser.c" />
<ClCompile Include="..\..\src\socket.c" />
<ClCompile Include="..\..\src\sporasub_sp2.c" />
<ClCompile Include="..\..\src\sporasub_sp2_parser.c" />
<ClCompile Include="..\..\src\suunto_common.c" />
<ClCompile Include="..\..\src\suunto_common2.c" />
<ClCompile Include="..\..\src\suunto_d9.c" />
<ClCompile Include="..\..\src\suunto_d9_parser.c" />
<ClCompile Include="..\..\src\suunto_eon.c" />
<ClCompile Include="..\..\src\suunto_eonsteel.c" />
<ClCompile Include="..\..\src\suunto_eonsteel_parser.c" />
<ClCompile Include="..\..\src\suunto_eon_parser.c" />
<ClCompile Include="..\..\src\suunto_solution.c" />
<ClCompile Include="..\..\src\suunto_solution_parser.c" />
<ClCompile Include="..\..\src\suunto_vyper.c" />
<ClCompile Include="..\..\src\suunto_vyper2.c" />
<ClCompile Include="..\..\src\suunto_vyper_parser.c" />
<ClCompile Include="..\..\src\tecdiving_divecomputereu.c" />
<ClCompile Include="..\..\src\tecdiving_divecomputereu_parser.c" />
<ClCompile Include="..\..\src\timer.c" />
<ClCompile Include="..\..\src\usb.c" />
<ClCompile Include="..\..\src\usbhid.c" />
<ClCompile Include="..\..\src\uwatec_aladin.c" />
<ClCompile Include="..\..\src\uwatec_memomouse.c" />
<ClCompile Include="..\..\src\uwatec_memomouse_parser.c" />
<ClCompile Include="..\..\src\uwatec_smart.c" />
<ClCompile Include="..\..\src\uwatec_smart_parser.c" />
<ClCompile Include="..\..\src\version.c" />
<ClCompile Include="..\..\src\zeagle_n2ition3.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\libdivecomputer\atomics_cobalt.h" />
<ClInclude Include="..\..\include\libdivecomputer\ble.h" />
<ClInclude Include="..\..\include\libdivecomputer\bluetooth.h" />
<ClInclude Include="..\..\include\libdivecomputer\buffer.h" />
<ClInclude Include="..\..\include\libdivecomputer\common.h" />
<ClInclude Include="..\..\include\libdivecomputer\context.h" />
<ClInclude Include="..\..\include\libdivecomputer\custom.h" />
<ClInclude Include="..\..\include\libdivecomputer\datetime.h" />
<ClInclude Include="..\..\include\libdivecomputer\descriptor.h" />
<ClInclude Include="..\..\include\libdivecomputer\device.h" />
<ClInclude Include="..\..\include\libdivecomputer\divesystem_idive.h" />
<ClInclude Include="..\..\include\libdivecomputer\hw_frog.h" />
<ClInclude Include="..\..\include\libdivecomputer\hw_ostc.h" />
<ClInclude Include="..\..\include\libdivecomputer\hw_ostc3.h" />
<ClInclude Include="..\..\include\libdivecomputer\ioctl.h" />
<ClInclude Include="..\..\include\libdivecomputer\iostream.h" />
<ClInclude Include="..\..\include\libdivecomputer\irda.h" />
<ClInclude Include="..\..\include\libdivecomputer\iterator.h" />
<ClInclude Include="..\..\include\libdivecomputer\oceanic_atom2.h" />
<ClInclude Include="..\..\include\libdivecomputer\oceanic_veo250.h" />
<ClInclude Include="..\..\include\libdivecomputer\oceanic_vtpro.h" />
<ClInclude Include="..\..\include\libdivecomputer\parser.h" />
<ClInclude Include="..\..\include\libdivecomputer\reefnet_sensus.h" />
<ClInclude Include="..\..\include\libdivecomputer\reefnet_sensuspro.h" />
<ClInclude Include="..\..\include\libdivecomputer\reefnet_sensusultra.h" />
<ClInclude Include="..\..\include\libdivecomputer\serial.h" />
<ClInclude Include="..\..\include\libdivecomputer\suunto_d9.h" />
<ClInclude Include="..\..\include\libdivecomputer\suunto_eon.h" />
<ClInclude Include="..\..\include\libdivecomputer\suunto_vyper2.h" />
<ClInclude Include="..\..\include\libdivecomputer\units.h" />
<ClInclude Include="..\..\include\libdivecomputer\usb.h" />
<ClInclude Include="..\..\include\libdivecomputer\usbhid.h" />
<ClInclude Include="..\..\include\libdivecomputer\version.h" />
<ClInclude Include="..\..\src\aes.h" />
<ClInclude Include="..\..\src\array.h" />
<ClInclude Include="..\..\src\atomics_cobalt.h" />
<ClInclude Include="..\..\src\checksum.h" />
<ClInclude Include="..\..\src\citizen_aqualand.h" />
<ClInclude Include="..\..\src\cochran_commander.h" />
<ClInclude Include="..\..\src\common-private.h" />
<ClInclude Include="..\..\src\context-private.h" />
<ClInclude Include="..\..\src\cressi_edy.h" />
<ClInclude Include="..\..\src\cressi_goa.h" />
<ClInclude Include="..\..\src\cressi_leonardo.h" />
<ClInclude Include="..\..\src\deepblu_cosmiq.h" />
<ClInclude Include="..\..\src\deepsix_excursion.h" />
<ClInclude Include="..\..\src\device-private.h" />
<ClInclude Include="..\..\src\diverite_nitekq.h" />
<ClInclude Include="..\..\src\divesoft_freedom.h" />
<ClInclude Include="..\..\src\divesystem_idive.h" />
<ClInclude Include="..\..\src\hdlc.h" />
<ClInclude Include="..\..\src\hw_frog.h" />
<ClInclude Include="..\..\src\hw_ostc.h" />
<ClInclude Include="..\..\src\hw_ostc3.h" />
<ClInclude Include="..\..\src\ihex.h" />
<ClInclude Include="..\..\src\iostream-private.h" />
<ClInclude Include="..\..\src\iterator-private.h" />
<ClInclude Include="..\..\src\liquivision_lynx.h" />
<ClInclude Include="..\..\src\mares_common.h" />
<ClInclude Include="..\..\src\mares_darwin.h" />
<ClInclude Include="..\..\src\mares_iconhd.h" />
<ClInclude Include="..\..\src\mares_nemo.h" />
<ClInclude Include="..\..\src\mares_puck.h" />
<ClInclude Include="..\..\src\mclean_extreme.h" />
<ClInclude Include="..\..\src\oceanic_atom2.h" />
<ClInclude Include="..\..\src\oceanic_common.h" />
<ClInclude Include="..\..\src\oceanic_veo250.h" />
<ClInclude Include="..\..\src\oceanic_vtpro.h" />
<ClInclude Include="..\..\src\oceans_s1.h" />
<ClInclude Include="..\..\src\oceans_s1_common.h" />
<ClInclude Include="..\..\src\packet.h" />
<ClInclude Include="..\..\src\parser-private.h" />
<ClInclude Include="..\..\src\pelagic_i330r.h" />
<ClInclude Include="..\..\src\platform.h" />
<ClInclude Include="..\..\src\rbstream.h" />
<ClInclude Include="..\..\src\reefnet_sensus.h" />
<ClInclude Include="..\..\src\reefnet_sensuspro.h" />
<ClInclude Include="..\..\src\reefnet_sensusultra.h" />
<ClInclude Include="..\..\src\revision.h" />
<ClInclude Include="..\..\src\ringbuffer.h" />
<ClInclude Include="..\..\src\seac_screen.h" />
<ClInclude Include="..\..\src\shearwater_common.h" />
<ClInclude Include="..\..\src\shearwater_petrel.h" />
<ClInclude Include="..\..\src\shearwater_predator.h" />
<ClInclude Include="..\..\src\socket.h" />
<ClInclude Include="..\..\src\sporasub_sp2.h" />
<ClInclude Include="..\..\src\suunto_common.h" />
<ClInclude Include="..\..\src\suunto_common2.h" />
<ClInclude Include="..\..\src\suunto_d9.h" />
<ClInclude Include="..\..\src\suunto_eon.h" />
<ClInclude Include="..\..\src\suunto_eonsteel.h" />
<ClInclude Include="..\..\src\suunto_solution.h" />
<ClInclude Include="..\..\src\suunto_vyper.h" />
<ClInclude Include="..\..\src\suunto_vyper2.h" />
<ClInclude Include="..\..\src\tecdiving_divecomputereu.h" />
<ClInclude Include="..\..\src\timer.h" />
<ClInclude Include="..\..\src\uwatec_aladin.h" />
<ClInclude Include="..\..\src\uwatec_memomouse.h" />
<ClInclude Include="..\..\src\uwatec_smart.h" />
<ClInclude Include="..\..\src\zeagle_n2ition3.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\libdivecomputer.rc" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\libdivecomputer.symbols">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
</Project>

View File

@ -1,35 +1,23 @@
# Atomic Aquatics Cobalt # Atomic Aquatics Cobalt
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", ATTR{idProduct}=="0888", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="0471", ATTR{idProduct}=="0888", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="0888", GROUP="plugdev"
# Suunto EON Steel # Suunto EON Steel
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0030", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0030", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0030", GROUP="plugdev"
# Suunto EON Core # Suunto EON Core
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0033", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0033", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0033", GROUP="plugdev"
# Suunto D5 # Suunto D5
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0035", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0035", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0035", GROUP="plugdev"
# Suunto EON Steel Black
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0036", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0036", GROUP="plugdev"
# Scubapro G2 # Scubapro G2
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3201", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3201", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="3201", GROUP="plugdev"
# Scubapro G2 Console # Scubapro G2 Console
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3211", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3211", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="3211", GROUP="plugdev"
# Scubapro G2 HUD # Scubapro G2 HUD
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="4201", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="4201", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="4201", GROUP="plugdev"
# Scubapro Aladin Square # Scubapro Aladin Square
SUBSYSTEM=="usb", ATTR{idVendor}=="c251", ATTR{idProduct}=="2006", GROUP="plugdev" SUBSYSTEM=="usb", ATTR{idVendor}=="c251", ATTR{idProduct}=="2006", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="c251", ATTRS{idProduct}=="2006", GROUP="plugdev"

View File

@ -1,102 +0,0 @@
COMPUTER CONFIGURATION
----------------------
The computer configuration (including gradient factors, gasses etc) is read and written as a single, fixed size block.
Config section
--------------
Computer configuration and individual dive configurations both start with identical generic configuration sections of length 0x002d bytes
0x0000 uint8_t format ZERO
0x0001 uint8_t gas[0]_pO2 oxygen content [0, 100] (percent)
0x0002 uint8_t gas[0]_pHe helium content [0, 100] (percent)
0x0003 uint8_t gas[1]_pO2 oxygen content [0, 100] (percent)
0x0004 uint8_t gas[1]_pHe helium content [0, 100] (percent)
0x0005 uint8_t gas[2]_pO2 oxygen content [0, 100] (percent)
0x0006 uint8_t gas[2]_pHe helium content [0, 100] (percent)
0x0007 uint8_t gas[3]_pO2 oxygen content [0, 100] (percent)
0x0008 uint8_t gas[3]_pHe helium content [0, 100] (percent)
0x0009 uint8_t gas[4]_pO2 oxygen content [0, 100] (percent)
0x000a uint8_t gas[4]_pHe helium content [0, 100] (percent)
0x000b uint8_t gas[5]_pO2 oxygen content [0, 100] (percent)
0x000c uint8_t gas[5]_pHe helium content [0, 100] (percent)
0x000d uint8_t gas[6]_pO2 oxygen content [0, 100] (percent)
0x000e uint8_t gas[6]_pHe helium content [0, 100] (percent)
0x000f uint8_t gas[7]_pO2 oxygen content [0, 100] (percent)
0x0010 uint8_t gas[7]_pHe helium content [0, 100] (percent)
0x0011 uint8_t gas_mask bitwise mask of enabled gasses
0x0012 uint8_t gas_active current gas index
0x0013 uint8_t setpoint[0] (centibar)
0x0014 uint8_t setpoint[1] (centibar)
0x0015 uint8_t setpoint[2] (centibar)
0x0016 uint8_t setpoint_mask bitwise mask of enabled setpoints
0x0017 uint8_t setpoint_active current setpoint index
0x0018 bool metric display units [true: metric, false: imperial]
0x0019 uint16_t name dive number
0x001b uint8_t laststop_index last stop depth enumeration [0, 3] (metric: 3m, 4m, 5m, 6m imperial: 10ft, 13ft, 16ft, 18ft)
0x001c uint16_t Vasc ascent speed limit (millibar/minute)
0x001e uint16_t Psurf surface pressure (millibar)
0x0020 uint8_t gfs_index predefined gf enumeration [0, 5] (only used in rec mode)
0x0021 uint8_t gf lo custom gf low [0, 255] (ignored in rec mode)
0x0022 uint8_t gf hi custom gf high [0, 255] (ignored in rec mode)
0x0023 uint8_t density_index predefined water density enumeration [0: 1.000, 1: 1.020, 2: 1.030]
0x0024 uint16_t ppN2_limit nitrogen partial pressure alert (millibars)
0x0026 uint16_t ppO2_limit oxygen partial pressure alert (millibars)
0x0028 uint16_t ppO2_bottomlimit oxygen partial pressure alert (millibars)
0x002a uint16_t density_limit (units ??)
0x002c uint8_t operatingmode operating mode enumeration [0: OC rec, 1: OC tec, 2: CC, 3: Gauge]
Computer configuration
----------------------
The computer configuration is read and written as a single block of 0x006a bytes formatted thusly:
<config section as above>
0x002d +
0x0000 int64_t epoch internal adjustment used to set computer time
0x0008 uint16_t inactive_timeout number of seconds of inactivity before the computer turns itself off
0x000a uint16_t dive_timeout number of seconds on surface before declaring dive finished
0x000c uint16_t log_period number of seconds between dive samples
0x000e uint16_t log_timeout not used
0x0010 uint16_t brightness_timeout number of seconds of inactivity before the computer dims the screen
0x0012 uint8_t brightness dimmed screen brightness [0, 10]
0x0013 uint8_t colorscheme computer color scheme enumeration [0, 12]
0x0014 uint8_t language computer display language enumeration [0, 1]
0x0015 uint8_t batterytype user-defined battery type enumeration [0, 4]
0x0016 uint16_t batterytime computer up time since last battery change
0x0018 <48 bytes> compass calibration data (cannot be written)
0x0048 uint8_t button_sensitivity piezo button sensitivity [0, 9]
0x0049 uint8_t orientation screen and button orientation
0x004a char[32] diver_name diver name (guaranteed at least one nul terminator)
0x006a
Dive configuration
------------------
Individual dives are read as a single block of 0x002d bytes formatted thusly:
<config section as above>
0x002d +
0x0000 uint32_t log_start log start (seconds since midnight 1 jan 2000)
0x0004 uint32_t dive_start dive start (seconds since midnight 1 jan 2000)
0x0008 uint32_t dive_end dive end (seconds since midnight 1 jan 2000)
0x000c uint32_t log_end log end (seconds since midnight 1 jan 2000)
0x0010 uint8_t temp_min minimum ambient temperature (degrees centigrade)
0x0011 uint8_t temp_max maximum ambient temperature (degrees centigrade)
0x0012 uint16_t pO2_min minimum inspired oxygen partial pressure during the dive (millibars)
0x0014 uint16_t pO2_max maximum inspired oxygen partial pressure during the dive (millibars)
0x0016 uint16_t Pmax maximum ambient pressure during the dive (millibars)
0x0018 uint16_t Pav average ambient pressure during the dive (millibars)
0x001a uint32_t ISS integral supersaturation of dive mbar*minutes
0x001e uint16_t CNS_start CNS at start of dive (percent)
0x0020 uint16_t CNS_max maximum CNS encountered during the dive (percent)
0x0022 uint16_t OTU OTU dive
0x0024 uint16_t tndl shortest NDL calculated during dive (seconds)
0x0026 uint32_t tdeco longest decompression time calculated during dive (seconds)
0x002a uint8_t ndeco deepest decompression stop index calculated during dive (seconds)
0x002b uint16_t tdesat desaturation time calculated at end of dive (seconds)
0x002d

View File

@ -17,7 +17,6 @@ MANPAGES = \
dc_descriptor_get_model.3 \ dc_descriptor_get_model.3 \
dc_descriptor_get_product.3 \ dc_descriptor_get_product.3 \
dc_descriptor_get_vendor.3 \ dc_descriptor_get_vendor.3 \
dc_descriptor_get_transports.3 \
dc_descriptor_iterator.3 \ dc_descriptor_iterator.3 \
dc_device_close.3 \ dc_device_close.3 \
dc_device_foreach.3 \ dc_device_foreach.3 \
@ -32,28 +31,7 @@ MANPAGES = \
dc_parser_get_field.3 \ dc_parser_get_field.3 \
dc_parser_new.3 \ dc_parser_new.3 \
dc_parser_samples_foreach.3 \ dc_parser_samples_foreach.3 \
dc_bluetooth_open.3 \ dc_parser_set_data.3 \
dc_bluetooth_iterator_new.3 \
dc_bluetooth_device_get_address.3 \
dc_bluetooth_device_get_name.3 \
dc_bluetooth_addr2str.3 \
dc_bluetooth_str2addr.3 \
dc_bluetooth_device_free.3 \
dc_usbhid_open.3 \
dc_usbhid_device_get_pid.3 \
dc_usbhid_device_get_vid.3 \
dc_usbhid_iterator_new.3 \
dc_usbhid_device_free.3 \
dc_serial_open.3 \
dc_serial_device_get_name.3 \
dc_serial_iterator_new.3 \
dc_serial_device_free.3 \
dc_irda_open.3 \
dc_irda_device_get_name.3 \
dc_irda_device_get_address.3 \
dc_irda_iterator_new.3 \
dc_irda_device_free.3 \
dc_iostream_close.3 \
libdivecomputer.3 libdivecomputer.3
HTMLPAGES = $(MANPAGES:%=%.html) HTMLPAGES = $(MANPAGES:%=%.html)

View File

@ -1,61 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_ADDR2STR 3
.Os
.Sh NAME
.Nm dc_bluetooth_addr2str
.Nd Convert a bluetooth address to a string.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft "const char*"
.Fo dc_bluetooth_addr2str
.Fa "dc_bluetooth_address_t address"
.Fa "char *str"
.Fa "size_t size"
.Fc
.Sh DESCRIPTION
Convert a bluetooth address to a string.
.Pp
The bluetooth address is formatted as XX:XX:XX:XX:XX:XX, where each XX is a
hexadecimal number specifying an octet of the 48-bit address.
The minimum size for the buffer is
.Dv DC_BLUETOOTH_SIZE
bytes.
.Pp
The reverse can be done with
.Xr dc_bluetooth_str2addr 3 .
.Sh RETURN VALUES
Returns the bluetooth address represented as a string.
.Sh SEE ALSO
.Xr dc_bluetooth_str2addr 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,52 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_DEVICE_FREE 3
.Os
.Sh NAME
.Nm dc_bluetooth_device_free
.Nd Destroy the bluetooth device and free all resources.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft void
.Fo dc_bluetooth_device_free
.Fa "dc_bluetooth_device_t *device"
.Fc
.Sh DESCRIPTION
Destroy the bluetooth device and free all resources.
The bluetooth
.Fa device
usually found by searching through
.Xr dc_bluetooth_iterator_new 3 .
.Sh SEE ALSO
.Xr dc_bluetooth_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,69 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_DEVICE_GET_ADDRESS 3
.Os
.Sh NAME
.Nm dc_bluetooth_device_get_address
.Nd Get the address of a bluetooth device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft "dc_bluetooth_address_t"
.Fo dc_bluetooth_device_get_address
.Fa "dc_bluetooth_device_t *device"
.Fc
.Sh DESCRIPTION
Get the bluetooth device address of given bluetooth
.Fa device .
Required when opening transport communication with
.Xr dc_bluetooth_open 3 .
Requires a valid
.Fa device
of type
.Ft dc_bluetooth_device_t
which can be retrieved using
.Xr dc_bluetooth_iterator_new 3 .
.Sh RETURN VALUES
Returns the bluetooth address of
.Fa device
as
.Ft dc_bluetooth_address_t
which is a 64bit integer holding the bluetooth address.
The address can be formatted as a string by using
.Xr dc_bluetooth_addr2str 3 .
.Sh SEE ALSO
.Xr dc_bluetooth_open 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_bluetooth_device_get_name 3 ,
.Xr dc_bluetooth_addr2str 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,61 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_DEVICE_GET_NAME 3
.Os
.Sh NAME
.Nm dc_bluetooth_device_get_name
.Nd Get the name of a bluetooth device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft "const char *"
.Fo dc_bluetooth_device_get_name
.Fa "dc_bluetooth_device_t *device"
.Fc
.Sh DESCRIPTION
Get the name of given bluetooth
.Fa device .
Used for displaying.
Requires a valid
.Fa bluetooth_device
of type
.Ft dc_bluetooth_device_t
which can be retrieved using
.Xr dc_bluetooth_iterator_new 3 .
.Sh RETURN VALUES
Returns the bluetooth device of
.Fa device .
.Sh SEE ALSO
.Xr dc_bluetooth_open 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_bluetooth_device_get_address 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,102 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_ITERATOR_NEW 3
.Os
.Sh NAME
.Nm dc_bluetooth_iterator_new
.Nd Create an iterator to enumerate the bluetooth devices.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft dc_status_t
.Fo dc_bluetooth_iterator_new
.Fa "dc_iterator_t **iterator"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Iterates through the available bluetooth devices which matches the given
.Fa descriptor .
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
the
.Fa iterator
will be set to an
.Ft dc_iterator_t
which can be used to iterate the available bluetooth devices using
.Xr dc_iterator_next 3 .
.Pp
The value type of the iterator is of type
.Ft dc_bluetooth_device_t .
This value can be used in functions to extract information about this specific bluetooth device, namely
.Xr dc_bluetooth_device_get_name 3
and
.Xr dc_bluetooth_device_get_address 3 .
When done the bluetooth device needs to be freed with
.Xr dc_bluetooth_device_free 3 .
.Pp
After iterating the
.Fa iterator
needs to be freed using
.Xr dc_iterator_free 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success, or another
.Ft dc_status_t
code on failure.
On
.Dv DC_STATUS_SUCCESS
the returned
.Fa iterator
needs to be freed when done using
.Xr dc_iterator_free 3 .
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_usbhid_iterator_new 3 ,
.Xr dc_serial_iterator_new 3 ,
.Xr dc_irda_iterator_new 3 ,
.Xr dc_bluetooth_device_get_name 3 ,
.Xr dc_bluetooth_device_get_address 3 ,
.Xr dc_bluetooth_device_free 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,87 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_OPEN 3
.Os
.Sh NAME
.Nm dc_bluetooth_open
.Nd Opens an iostream for a bluetooth device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft dc_status_t
.Fo dc_bluetooth_open
.Fa "dc_iostream_t **iostream"
.Fa "dc_context_t *context"
.Fa "dc_bluetooth_address_t address"
.Fa "unsigned int port"
.Fc
.Sh DESCRIPTION
Opens an iostream for a bluetooth device.
Accepts a
.Fa context
opened with
.Xr dc_context_new 3 ,
a 48-bit bluetooth
.Fa address
given by
.Xr dc_bluetooth_iterator_new 3
together with
.Xr dc_bluetooth_device_get_address 3
or
.Xr dc_bluetooth_str2addr 3
and a bluetooth rfcomm
.Fa port
number (use 0 for autodetection).
.Pp
Upon returning
.Dv DC_STATUS_SUCCESS ,
the
.Fa iostream
pointer must be freed with
.Xr dc_iostream_close 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
On success, the
.Fa iostream
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_iostream_close 3 ,
.Xr dc_serial_open 3 ,
.Xr dc_irda_open 3 ,
.Xr dc_usbhid_open 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_bluetooth_device_get_address 3 ,
.Xr dc_bluetooth_str2addr 3 ,
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,58 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_BLUETOOTH_STR2ADDR 3
.Os
.Sh NAME
.Nm dc_bluetooth_str2addr
.Nd Convert a string to a bluetooth address.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/bluetooth.h
.Ft "dc_bluetooth_address_t"
.Fo dc_bluetooth_addr2str
.Fa "const char *address"
.Fc
.Sh DESCRIPTION
Convert a string to a bluetooth address.
.Pp
The string
.Fa address
is expected to be in the format XX:XX:XX:XX:XX:XX,
where each XX is a hexadecimal number specifying an octet of the 48-bit address.
.Pp
The reverse can be done with
.Xr dc_bluetooth_addr2str 3 .
.Sh RETURN VALUES
Returns the bluetooth address represented as a 48-bit number.
.Sh SEE ALSO
.Xr dc_bluetooth_addr2str 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -82,7 +82,7 @@ is
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_datetime_localtime 3 , .Xr dc_datetime_localtime 3 ,
.Xr dc_datetime_mktime 3 , .Xr dc_datetime_mktime 3 ,
.Xr dc_datetime_now 3 .Xr dc_datetime_new 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -82,7 +82,7 @@ is
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_datetime_gmtime 3 , .Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_mktime 3 , .Xr dc_datetime_mktime 3 ,
.Xr dc_datetime_now 3 .Xr dc_datetime_new 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -47,7 +47,7 @@ may not sanely be converted.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_datetime_gmtime 3 , .Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_localtime 3 , .Xr dc_datetime_localtime 3 ,
.Xr dc_datetime_now 3 .Xr dc_datetime_new 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -1,72 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_DESCRIPTOR_GET_TRANSPORTS 3
.Os
.Sh NAME
.Nm dc_descriptor_get_transports
.Nd Gets the transports supported by the given descriptor.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/descriptor.h
.Ft "unsigned int"
.Fo dc_descriptor_get_transports
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Gets the transports supported by the given
.Fa descriptor .
The
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Sh RETURN VALUES
Returns a union (bitwise OR) of the transports supported by the given
.Fa descriptor .
.Pp
The result is combination of
.Dv DC_TRANSPORT_USB ,
.Dv DC_TRANSPORT_USBHID ,
.Dv DC_TRANSPORT_BLE ,
.Dv DC_TRANSPORT_BLUETOOTH ,
.Dv DC_TRANSPORT_SERIAL ,
.Dv DC_TRANSPORT_IRDA
.Pp
To determine if a specific transport is supported use the following code
.Bd -literal -offset indent
unsigned int transports = dc_descriptor_get_transports(descriptor);
if(transports & DC_TRANSPORT_USBHID) {
// Device supports USB HID as transport
}
.Ed
.Sh SEE ALSO
.Xr dc_descriptor_iterator 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -53,7 +53,7 @@ with
Each dive invokes Each dive invokes
.Fa callback .Fa callback
with the dive data, which should be parsed with with the dive data, which should be parsed with
.Xr dc_parser_new 3 , .Xr dc_parser_set_data 3 ,
and the binary fingerprint of the dive. and the binary fingerprint of the dive.
The fingerprint can be used to record the newest dive and stop The fingerprint can be used to record the newest dive and stop
processing (on subsequent invocations) when the same dive fingerprint is processing (on subsequent invocations) when the same dive fingerprint is
@ -72,7 +72,7 @@ If
returns zero, this will not be reflected in the return value (usually returns zero, this will not be reflected in the return value (usually
.Dv DC_STATUS_SUCCESS ) . .Dv DC_STATUS_SUCCESS ) .
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_parser_new 3 .Xr dc_parser_set_data 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -18,7 +18,7 @@
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA .\" MA 02110-1301 USA
.\" .\"
.Dd June 5, 2020 .Dd January 5, 2017
.Dt DC_DEVICE_OPEN 3 .Dt DC_DEVICE_OPEN 3
.Os .Os
.Sh NAME .Sh NAME
@ -33,7 +33,7 @@
.Fa "dc_device_t **device" .Fa "dc_device_t **device"
.Fa "dc_context_t *context" .Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor" .Fa "dc_descriptor_t *descriptor"
.Fa "dc_iostream_t *iostream" .Fa "const char *name"
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
Open a dive computer device for processing. Open a dive computer device for processing.
@ -45,14 +45,19 @@ a dive computer
.Fa descriptor .Fa descriptor
usually found by searching through usually found by searching through
.Xr dc_descriptor_iterator 3 , .Xr dc_descriptor_iterator 3 ,
and a and a platform-specific device
.Fa iostream .Fa name
opened with a transport specific open function like .Po
.Xr dc_usbhid_open 3 , such as
.Xr dc_irda_open 3 , .Pa /dev/ttyUSBx
.Xr dc_serial_open 3 , on Linux,
.Pa /dev/tty.xxx
on Mac OS X,
.Pa /dev/ttyUx
on the BSDs,
or or
.Xr dc_bluetooth_open 3 .Pa COMx
on Microsoft Windows
.Pc . .Pc .
.Pp .Pp
Upon returning Upon returning
@ -78,10 +83,6 @@ The
library was written by library was written by
.An Jef Driesen , .An Jef Driesen ,
.Mt jef@libdivecomputer.org . .Mt jef@libdivecomputer.org .
.br
The manpages were written by The manpages were written by
.An Kristaps Dzonsons , .An Kristaps Dzonsons ,
.Mt kristaps@bsd.lv . .Mt kristaps@bsd.lv .
and
.An Vincent Hagen ,
.Mt vinnie@script4web.nl

View File

@ -1,52 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_IRDA_DEVICE_FREE 3
.Os
.Sh NAME
.Nm dc_irda_device_free
.Nd Destroy the irda device and free all resources.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/irda.h
.Ft void
.Fo dc_irda_device_free
.Fa "dc_irda_device_t *device"
.Fc
.Sh DESCRIPTION
Destroy the irda device and free all resources.
The irda
.Fa device
usually found by searching through
.Xr dc_irda_iterator_new 3 .
.Sh SEE ALSO
.Xr dc_irda_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,59 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_IRDA_DEVICE_GET_ADDRESS 3
.Os
.Sh NAME
.Nm dc_irda_device_get_address
.Nd Get the address of the IrDA device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/irda.h
.Ft "unsigned int"
.Fo dc_irda_device_get_address
.Fa "dc_irda_device_t *device"
.Fc
.Sh DESCRIPTION
Get the address of the IrDA device. Return value used for opening a IrDA device using
.Xr dc_irda_open 3 .
Requires a valid irda
.Fa device
of type
.Ft dc_irda_device_t
which can be retrieved using
.Xr dc_irda_iterator_new 3 .
.Sh RETURN VALUES
Returns the IrDA address of given IrDA
.Fa device
.Sh SEE ALSO
.Xr dc_irda_open 3 ,
.Xr dc_irda_device_get_name 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,58 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_IRDA_DEVICE_GET_NAME 3
.Os
.Sh NAME
.Nm dc_irda_device_get_name
.Nd Get the address of the IrDA device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/irda.h
.Ft "const char *"
.Fo dc_irda_device_get_name
.Fa "dc_irda_device_t *device"
.Fc
.Sh DESCRIPTION
Get the name of the IrDA device. Used for displaying.
Requires a valid irda
.Fa device
of type
.Ft dc_irda_device_t
which can be retrieved using
.Xr dc_irda_iterator_new 3 .
.Sh RETURN VALUES
Returns the IrDA name of given
.Fa irda_device
.Sh SEE ALSO
.Xr dc_irda_device_get_address 3 .
.Xr dc_irda_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,102 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_IRDA_ITERATOR_NEW 3
.Os
.Sh NAME
.Nm dc_irda_iterator_new
.Nd Create an iterator to enumerate the IrDA devices.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/irda.h
.Ft dc_status_t
.Fo dc_irda_iterator_new
.Fa "dc_iterator_t **iterator"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Iterates through the available IrDA devices which matches the given
.Fa descriptor .
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
the
.Fa iterator
will be set to an
.Ft dc_iterator_t
which can be used to iterate the available IrDA devices using
.Xr dc_iterator_next 3 .
.Pp
The value type of the iterator is of type
.Ft dc_irda_device_t .
This value can be used in functions to extract information about this specific IrDA device, namely
.Xr dc_irda_device_get_name 3
and
.Xr dc_irda_device_get_address 3 .
When done the IrDA device needs to be freed with
.Xr dc_irda_device_free 3 .
.Pp
After iterating the
.Fa iterator
needs to be freed using
.Xr dc_iterator_free 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success, or another
.Ft dc_status_t
code on failure.
On
.Dv DC_STATUS_SUCCESS
the returned
.Fa iterator
needs to be freed when done using
.Xr dc_iterator_free 3 .
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_usbhid_iterator_new 3 ,
.Xr dc_serial_iterator_new 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_irda_device_get_name 3 ,
.Xr dc_irda_device_get_address 3 ,
.Xr dc_irda_device_free 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,85 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_IRDA_OPEN 3
.Os
.Sh NAME
.Nm dc_irda_open
.Nd Opens an iostream for a IrDA device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/irda.h
.Ft dc_status_t
.Fo dc_irda_open
.Fa "dc_iostream_t **iostream"
.Fa "dc_context_t *context"
.Fa "unsigned int address"
.Fa "unsigned int lsap"
.Fc
.Sh DESCRIPTION
Opens an iostream for a IrDA (Infra Red) device.
Accepts a
.Fa context
opened with
.Xr dc_context_new 3 ,
.Fa address
given through
.Xr dc_irda_iterator_new 3
together with
.Xr dc_irda_device_get_address 3
, the last argument
.Fa lsap
is a port number used during the communication. Currently only Uwatec computers use IrDA comminication and for those the
.Fa lsap
can be hardcoded to 1
.Pp
Upon returning
.Dv DC_STATUS_SUCCESS ,
the
.Fa iostream
pointer must be freed with
.Xr dc_iostream_close 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
On success, the
.Fa iostream
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_iostream_close 3 ,
.Xr dc_serial_open 3 ,
.Xr dc_usbhid_open 3 ,
.Xr dc_bluetooth_open 3 ,
.Xr dc_irda_iterator_new 3 ,
.Xr dc_irda_device_get_address 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -37,7 +37,7 @@
Extract the date and time of a dive, Extract the date and time of a dive,
.Fa parser , .Fa parser ,
previously initialised with previously initialised with
.Xr dc_parser_new 3 . .Xr dc_parser_set_data 3 .
This returns the broken-down time-stamp of the dive in the local time of This returns the broken-down time-stamp of the dive in the local time of
the dive. the dive.
.Pp .Pp
@ -57,7 +57,7 @@ messages on further failure.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_datetime_gmtime 3 , .Xr dc_datetime_gmtime 3 ,
.Xr dc_datetime_localtime 3 , .Xr dc_datetime_localtime 3 ,
.Xr dc_parser_new 3 .Xr dc_parser_set_data 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -39,7 +39,7 @@
Extract a field from a dive, Extract a field from a dive,
.Fa parser , .Fa parser ,
previously initialised with previously initialised with
.Xr dc_parser_new 3 . .Xr dc_parser_set_data 3 .
The The
.Fa value .Fa value
field type depends upon the field type depends upon the
@ -149,7 +149,7 @@ the tank volume units as
or or
.Dv DC_TANKVOLUME_METRIC ; .Dv DC_TANKVOLUME_METRIC ;
.Va volume , .Va volume ,
the tank volume in litres or zero if the tank is the tank volume in bar or zero if the tank is
.Dv DC_TANKVOLUME_NONE ; .Dv DC_TANKVOLUME_NONE ;
.Va workpressure , .Va workpressure ,
the work pressure in bar or zero if the work pressure in bar or zero if
@ -187,7 +187,7 @@ if the field was retrieved,
if the field is not supported by the device, or other error messages on if the field is not supported by the device, or other error messages on
further failure. further failure.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_parser_new 3 .Xr dc_parser_set_data 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -39,6 +39,8 @@
.Fa "dc_parser_t **parser" .Fa "dc_parser_t **parser"
.Fa "dc_context_t *context" .Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor" .Fa "dc_descriptor_t *descriptor"
.Fa "unsigned int devtime"
.Fa "dc_ticks_t systime"
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
Creates a parser for a single dive extracted from the dive computer with Creates a parser for a single dive extracted from the dive computer with
@ -53,6 +55,10 @@ parameter; and
.Nm dc_parser_new2 , .Nm dc_parser_new2 ,
which is given device values (model, etc.) directly. which is given device values (model, etc.) directly.
.Pp .Pp
After filling in the
.Fa parser
parameter, one usually sets parser data with
.Xr dc_parser_set_data 3 .
The pointer must later be freed with The pointer must later be freed with
.Xr dc_parser_destroy 3 . .Xr dc_parser_destroy 3 .
.Sh RETURN VALUES .Sh RETURN VALUES

View File

@ -31,7 +31,7 @@
.Ft "typedef void" .Ft "typedef void"
.Fo "(*dc_sample_callback_t)" .Fo "(*dc_sample_callback_t)"
.Fa "dc_sample_type_t type" .Fa "dc_sample_type_t type"
.Fa "const dc_sample_value_t *value" .Fa "dc_sample_value_t value"
.Fa "void *userdata" .Fa "void *userdata"
.Fc .Fc
.Ft dc_status_t .Ft dc_status_t
@ -42,7 +42,7 @@
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
Extract the samples taken during a dive as previously initialised with Extract the samples taken during a dive as previously initialised with
.Xr dc_parser_new 3 . .Xr dc_parser_set_data 3 .
Each sample is passed to Each sample is passed to
.Fa callback .Fa callback
with the with the
@ -63,7 +63,7 @@ closed.
The following sample types may be raised: The following sample types may be raised:
.Bl -tag -width Ds .Bl -tag -width Ds
.It Dv DC_SAMPLE_TIME .It Dv DC_SAMPLE_TIME
The time of the sample taken in milliseconds after the dive began. The time of the sample taken in seconds after the dive began.
Set in the Set in the
.Fa time .Fa time
field. field.
@ -126,7 +126,7 @@ Sets the
.Fa rbt .Fa rbt
field. field.
.It Dv DC_SAMPLE_HEARTBEAT .It Dv DC_SAMPLE_HEARTBEAT
The diver's heartbeat in beats per minute. The diver's heartbeet in beats per minute.
Sets the Sets the
.Fa heartbeat .Fa heartbeat
field. field.
@ -184,7 +184,7 @@ Returns
.Dv DC_STATUS_OK .Dv DC_STATUS_OK
on success and another code on failure. on success and another code on failure.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_parser_new 3 .Xr dc_parser_set_data 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -1,7 +1,7 @@
.\" .\"
.\" libdivecomputer .\" libdivecomputer
.\" .\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl> .\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
.\" .\"
.\" This library is free software; you can redistribute it and/or .\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public .\" modify it under the terms of the GNU Lesser General Public
@ -18,43 +18,48 @@
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, .\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA .\" MA 02110-1301 USA
.\" .\"
.Dd June 5, 2020 .Dd January 5, 2017
.Dt DC_IOSTREAM_CLOSE 3 .Dt DC_PARSER_SET_DATA 3
.Os .Os
.Sh NAME .Sh NAME
.Nm dc_iostream_close .Nm dc_parser_set_data
.Nd Close the I/O stream and free all resources. .Nd assigns parse data to a dive parser
.Sh LIBRARY .Sh LIBRARY
.Lb libdivecomputer .Lb libdivecomputer
.Sh SYNOPSIS .Sh SYNOPSIS
.In libdivecomputer/iostream.h .In libdivecomputer/parser.h
.Ft dc_status_t .Ft dc_status_t
.Fo dc_iostream_close .Fo dc_parser_set_data
.Fa "dc_iostream_t *iostream" .Fa "dc_parser_t *parser"
.Fa "const unsigned char *data"
.Fa "unsigned int size"
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
Close the I/O stream and free all resources. Assigns the binary sequence
Accepts the .Fa data
.Fa iostream of length
to close and free. .Fa size
bytes to
.Fa parser ,
which was created with
.Xr dc_parser_new 3 .
How the data is parsed depends upon the values provided to
.Xr dc_parser_new 3 .
The data usually comes from the callback assigned to
.Xr dc_device_foreach 3 .
.Sh RETURN VALUES .Sh RETURN VALUES
Returns Returns
.Dv DC_STATUS_SUCCESS .Dv DC_STATUS_OK
on success, or another on success and another code on failure.
.Ft dc_status_t
code on failure.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_usbhid_open 3 , .Xr dc_device_foreach 3 ,
.Xr dc_serial_open 3 , .Xr dc_parser_new 3
.Xr dc_irda_open 3 ,
.Xr dc_bluetooth_open 3 .
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer
library was written by library was written by
.An Jef Driesen , .An Jef Driesen ,
.Mt jef@libdivecomputer.org . .Mt jef@libdivecomputer.org .
.br The manpages were written by
This manpage is written by .An Kristaps Dzonsons ,
.An Vincent Hagen , .Mt kristaps@bsd.lv .
.Mt vinnie@script4web.nl .

View File

@ -1,52 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_SERIAL_DEVICE_FREE 3
.Os
.Sh NAME
.Nm dc_serial_device_free
.Nd Destroy the serial device and free all resources.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/serial.h
.Ft void
.Fo dc_serial_device_free
.Fa "dc_serial_device_t *device"
.Fc
.Sh DESCRIPTION
Destroy the serial device and free all resources.
The serial
.Fa device
usually found by searching through
.Xr dc_serial_iterator_new 3 .
.Sh SEE ALSO
.Xr dc_serial_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,59 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_SERIAL_DEVICE_GET_NAME 3
.Os
.Sh NAME
.Nm dc_serial_device_get_name
.Nd Get the device name of the serial device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/serial.h
.Ft "const char *"
.Fo dc_serial_device_get_name
.Fa "dc_serial_device_t *device"
.Fc
.Sh DESCRIPTION
Get the device node of the serial device. Used when opening serial transport with
.Xr dc_serial_open 3 .
Requires a valid serial
.Fa device
of type
.Ft dc_serial_device_t
which can be retrieved using
.Xr dc_serial_iterator_new 3 .
.Sh RETURN VALUES
Returns the device name of given serial
.Fa device
.Sh SEE ALSO
.Xr dc_serial_open 3 ,
.Xr dc_serial_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,99 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_SERIAL_ITERATOR_NEW 3
.Os
.Sh NAME
.Nm dc_serial_iterator_new
.Nd Create an iterator to enumerate the serial devices.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/serial.h
.Ft dc_status_t
.Fo dc_serial_iterator_new
.Fa "dc_iterator_t **iterator"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Iterates through the available serial devices matching the given
.Fa descriptor .
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
the
.Fa iterator
will be set to an
.Ft dc_iterator_t
which can be used to iterate the available serial devices using
.Xr dc_iterator_next 3 .
.Pp
The value type of the iterator is of type
.Ft dc_serial_device_t .
This value can be used in functions to extract information about this specific serial device, namely
.Xr dc_serial_device_get_name 3
When done the serial device needs to be freed with
.Xr dc_serial_device_free 3 .
.Pp
After iterating the
.Fa iterator
needs to be freed using
.Xr dc_iterator_free 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success, or another
.Ft dc_status_t
code on failure.
On
.Dv DC_STATUS_SUCCESS
the returned
.Fa iterator
needs to be freed when done using
.Xr dc_iterator_free 3 .
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_usbhid_iterator_new 3 ,
.Xr dc_irda_iterator_new 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_serial_device_get_name 3 ,
.Xr dc_serial_device_free 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,80 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_SERIAL_OPEN 3
.Os
.Sh NAME
.Nm dc_serial_open
.Nd Opens an iostream for a serial device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/serial.h
.Ft dc_status_t
.Fo dc_serial_open
.Fa "dc_iostream_t **iostream"
.Fa "dc_context_t *context"
.Fa "const char *name"
.Fc
.Sh DESCRIPTION
Opens an iostream for a serial device.
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa name
device name, usually found through
.Xr dc_serial_iterator_new 3
with
.Xr dc_serial_device_get_name 3 .
.Pp
Upon returning
.Dv DC_STATUS_SUCCESS ,
the
.Fa iostream
pointer must be freed with
.Xr dc_iostream_close 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
On success, the
.Fa iostream
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_iostream_close 3 ,
.Xr dc_usbhid_open 3 ,
.Xr dc_irda_open 3 ,
.Xr dc_bluetooth_open 3 ,
.Xr dc_serial_iterator_new 3 ,
.Xr dc_serial_device_get_name 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,52 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_USBHID_DEVICE_FREE 3
.Os
.Sh NAME
.Nm dc_usbhid_device_free
.Nd Destroy the USB HID device and free all resources.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/usbhid.h
.Ft void
.Fo dc_usbhid_device_free
.Fa "dc_usbhid_device_t *device"
.Fc
.Sh DESCRIPTION
Destroy the USB HID device and free all resources.
The usbhid
.Fa device
usually found by searching through
.Xr dc_usbhid_iterator_new 3 .
.Sh SEE ALSO
.Xr dc_usbhid_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,58 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_USBHID_DEVICE_GET_PID 3
.Os
.Sh NAME
.Nm dc_usbhid_device_get_pid
.Nd Get the product id (PID) of the USB HID device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/usbhid.h
.Ft "unsigned int"
.Fo dc_usbhid_device_get_pid
.Fa "dc_usbhid_device_t *device"
.Fc
.Sh DESCRIPTION
Get the product id (PID) of the USB HID device. Used for displaying.
Requires a valid usbhid
.Fa device
of type
.Ft dc_usbhid_device_t
which can be retrieved using
.Xr dc_usbhid_iterator_new 3 .
.Sh RETURN VALUES
Returns the product id (PID) of given
.Fa usbhid_device
.Sh SEE ALSO
.Xr dc_usbhid_device_get_vid 3 ,
.Xr dc_usbhid_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,58 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_USBHID_DEVICE_GET_VID 3
.Os
.Sh NAME
.Nm dc_usbhid_device_get_vid
.Nd Get the vendor id (VID) of the USB HID device.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/usbhid.h
.Ft "unsigned int"
.Fo dc_usbhid_device_get_vid
.Fa "dc_usbhid_device_t *device"
.Fc
.Sh DESCRIPTION
Get the vendor id (VID) of the USB HID device. Used for displaying.
Requires a valid usbhid
.Fa device
of type
.Ft dc_usbhid_device_t
which can be retrieved using
.Xr dc_usbhid_iterator_new 3 .
.Sh RETURN VALUES
Returns the vendor id (VID) of given usbhid
.Fa device
.Sh SEE ALSO
.Xr dc_usbhid_device_get_vid 3 ,
.Xr dc_usbhid_iterator_new 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,101 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_USBHID_ITERATOR_NEW 3
.Os
.Sh NAME
.Nm dc_usbhid_iterator_new
.Nd Create an iterator to enumerate the USB HID devices.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/usbhid.h
.Ft dc_status_t
.Fo dc_usbhid_iterator_new
.Fa "dc_iterator_t **iterator"
.Fa "dc_context_t *context"
.Fa "dc_descriptor_t *descriptor"
.Fc
.Sh DESCRIPTION
Iterates through the available USB HID devices matching the given
.Fa descriptor .
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa descriptor
usually found by searching through
.Xr dc_descriptor_iterator 3 .
.Pp
On returning
.Dv DC_STATUS_SUCCESS
the
.Fa iterator
will be set to an
.Ft dc_iterator_t
which can be used to iterate the available USB HID devices using
.Xr dc_iterator_next 3 .
.Pp
The value type of the iterator is of type
.Ft dc_usbhid_device_t .
This value can be used in functions to extract information about this specific USB HID device, namely
.Xr dc_usbhid_device_get_pid 3
and
.Xr dc_usbhid_device_get_vid 3 .
When done the USB HID device needs to be freed with
.Xr dc_usbhid_device_free 3 .
.Pp
After iterating the
.Fa iterator
needs to be freed using
.Xr dc_iterator_free 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success, or another
.Ft dc_status_t
code on failure.
On
.Dv DC_STATUS_SUCCESS
the returned
.Fa iterator
needs to be freed when done using
.Xr dc_iterator_free 3 .
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_bluetooth_iterator_new 3 ,
.Xr dc_serial_iterator_new 3 ,
.Xr dc_irda_iterator_new 3 ,
.Xr dc_usbhid_device_get_pid 3 ,
.Xr dc_usbhid_device_get_vid 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -1,77 +0,0 @@
.\"
.\" libdivecomputer
.\"
.\" Copyright (C) 2020 Vincent Hagen <vinnie@script4web.nl>
.\"
.\" This library is free software; you can redistribute it and/or
.\" modify it under the terms of the GNU Lesser General Public
.\" License as published by the Free Software Foundation; either
.\" version 2.1 of the License, or (at your option) any later version.
.\"
.\" This library is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
.\" Lesser General Public License for more details.
.\"
.\" You should have received a copy of the GNU Lesser General Public
.\" License along with this library; if not, write to the Free Software
.\" Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
.\" MA 02110-1301 USA
.\"
.Dd June 5, 2020
.Dt DC_USBHID_OPEN 3
.Os
.Sh NAME
.Nm dc_usbhid_open
.Nd Opens an iostream for a USB HID device
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/usbhid.h
.Ft dc_status_t
.Fo dc_usbhid_open
.Fa "dc_iostream_t **iostream"
.Fa "dc_context_t *context"
.Fa "dc_usbhid_device_t *device"
.Fc
.Sh DESCRIPTION
Opens an iostream for a USB HID device.
Accepts a
.Fa context
opened with
.Xr dc_context_new 3
and a
.Fa device
usually found by searching through
.Xr dc_usbhid_iterator_new 3 .
.Pp
Upon returning
.Dv DC_STATUS_SUCCESS ,
the
.Fa iostream
pointer must be freed with
.Xr dc_iostream_close 3 .
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success or one of several error values on error.
On success, the
.Fa iostream
pointer is filled in with an open handle.
.Sh SEE ALSO
.Xr dc_context_new 3 ,
.Xr dc_usbhid_iterator_new 3 ,
.Xr dc_iostream_close 3 ,
.Xr dc_serial_open 3 ,
.Xr dc_irda_open 3 ,
.Xr dc_bluetooth_open 3 .
.Sh AUTHORS
The
.Lb libdivecomputer
library was written by
.An Jef Driesen ,
.Mt jef@libdivecomputer.org .
.br
This manpage is written by
.An Vincent Hagen ,
.Mt vinnie@script4web.nl .

View File

@ -41,8 +41,9 @@ these steps:
.Bl -enum .Bl -enum
.It .It
Create a new context with Create a new context with
.Xr dc_context_new 3 .Xr dc_context_new 3 .
to initialize the library. Logging can be controlled with This supplies a parse context: logging, error handling, etc.
Override the values with
.Xr dc_context_set_logfunc 3 .Xr dc_context_set_logfunc 3
and and
.Xr dc_context_set_loglevel 3 . .Xr dc_context_set_loglevel 3 .
@ -51,28 +52,11 @@ Find a descriptor for their dive computer by iterating through
.Xr dc_descriptor_iterator 3 .Xr dc_descriptor_iterator 3
and searching by name, vendor, or product family. and searching by name, vendor, or product family.
.It .It
Find the transport to use for the communication. To determine the supported transports use Open the hardware device to which the dive computer is connected with
.Xr dc_descriptor_get_transports 3 . .Xr dc_device_open 3 ,
.It then invoke
Find the hardware device corresponding to the connected dive computer by iterating through
.Xr dc_usbhid_iterator_new 3 ,
.Xr dc_serial_iterator_new 3 ,
.Xr dc_irda_iterator_new 3
or
.Xr dc_bluetooth_iterator_new 3 .
.It
Open the transport communcations with
.Xr dc_usbhid_open 3 ,
.Xr dc_serial_open 3 ,
.Xr dc_irda_open 3
or
.Xr dc_bluetooth_open 3 .
.It
Open a connection to the dive computer with
.Xr dc_device_open 3 .
Optionally use
.Xr dc_device_set_events 3 , .Xr dc_device_set_events 3 ,
.Xr dc_device_set_fingerprint 3 .Xr dc_device_set_fingerprint 3 ,
and and
.Xr dc_device_set_cancel 3 .Xr dc_device_set_cancel 3
to set the logging events, last-seen fingerprint, and cancel routine, to set the logging events, last-seen fingerprint, and cancel routine,
@ -82,12 +66,13 @@ Iterate over all dives with
.Xr dc_device_foreach 3 . .Xr dc_device_foreach 3 .
.It .It
For each iterated dive, create a new parser with For each iterated dive, create a new parser with
.Xr dc_parser_new 3 . .Xr dc_parser_new 3
and set the parsed data with
.Xr dc_parser_set_data 3 .
.It .It
Get attributes of the parsed dive with Get attributes of the parsed dive with
.Xr dc_parser_get_field 3 . .Xr dc_parser_get_field 3 ,
.It then iterate through the dive's samples (recorded data) with
Iterate through the dive's samples (recorded data) with
.Xr dc_parser_samples_foreach 3 . .Xr dc_parser_samples_foreach 3 .
.El .El
.Sh RETURN VALUES .Sh RETURN VALUES
@ -144,10 +129,7 @@ return
.Dv DC_STATUS_SUCCESS . .Dv DC_STATUS_SUCCESS .
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_context_new 3 , .Xr dc_buffer_new 3
.Xr dc_descriptor_iterator 3
.Xr dc_device_open 3
.Xr dc_parser_new 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

View File

@ -31,7 +31,6 @@
#include <libdivecomputer/serial.h> #include <libdivecomputer/serial.h>
#include <libdivecomputer/bluetooth.h> #include <libdivecomputer/bluetooth.h>
#include <libdivecomputer/irda.h> #include <libdivecomputer/irda.h>
#include <libdivecomputer/usb.h>
#include <libdivecomputer/usbhid.h> #include <libdivecomputer/usbhid.h>
#include "common.h" #include "common.h"
@ -72,7 +71,6 @@ static const backend_table_t g_backends[] = {
{"vtpro", DC_FAMILY_OCEANIC_VTPRO, 0x4245}, {"vtpro", DC_FAMILY_OCEANIC_VTPRO, 0x4245},
{"veo250", DC_FAMILY_OCEANIC_VEO250, 0x424C}, {"veo250", DC_FAMILY_OCEANIC_VEO250, 0x424C},
{"atom2", DC_FAMILY_OCEANIC_ATOM2, 0x4342}, {"atom2", DC_FAMILY_OCEANIC_ATOM2, 0x4342},
{"i330r", DC_FAMILY_PELAGIC_I330R, 0x4744},
{"nemo", DC_FAMILY_MARES_NEMO, 0}, {"nemo", DC_FAMILY_MARES_NEMO, 0},
{"puck", DC_FAMILY_MARES_PUCK, 7}, {"puck", DC_FAMILY_MARES_PUCK, 7},
{"darwin", DC_FAMILY_MARES_DARWIN, 0}, {"darwin", DC_FAMILY_MARES_DARWIN, 0},
@ -92,17 +90,8 @@ static const backend_table_t g_backends[] = {
{"idive", DC_FAMILY_DIVESYSTEM_IDIVE, 0x03}, {"idive", DC_FAMILY_DIVESYSTEM_IDIVE, 0x03},
{"cochran", DC_FAMILY_COCHRAN_COMMANDER, 0}, {"cochran", DC_FAMILY_COCHRAN_COMMANDER, 0},
{"divecomputereu", DC_FAMILY_TECDIVING_DIVECOMPUTEREU, 0}, {"divecomputereu", DC_FAMILY_TECDIVING_DIVECOMPUTEREU, 0},
{"extreme", DC_FAMILY_MCLEAN_EXTREME, 0}, {"descentmk1", DC_FAMILY_GARMIN, 0},
{"lynx", DC_FAMILY_LIQUIVISION_LYNX, 0}, {"cosmiq", DC_FAMILY_DEEPBLU, 0},
{"sp2", DC_FAMILY_SPORASUB_SP2, 0},
{"excursion", DC_FAMILY_DEEPSIX_EXCURSION, 0},
{"screen", DC_FAMILY_SEAC_SCREEN, 0},
{"cosmiq", DC_FAMILY_DEEPBLU_COSMIQ, 0},
{"s1", DC_FAMILY_OCEANS_S1, 0},
{"freedom", DC_FAMILY_DIVESOFT_FREEDOM, 19},
// Not merged upstream yet
{"descentmk1", DC_FAMILY_GARMIN, 0},
}; };
static const transport_table_t g_transports[] = { static const transport_table_t g_transports[] = {
@ -112,8 +101,6 @@ static const transport_table_t g_transports[] = {
{"irda", DC_TRANSPORT_IRDA}, {"irda", DC_TRANSPORT_IRDA},
{"bluetooth", DC_TRANSPORT_BLUETOOTH}, {"bluetooth", DC_TRANSPORT_BLUETOOTH},
{"ble", DC_TRANSPORT_BLE}, {"ble", DC_TRANSPORT_BLE},
// Not merged upstream yet
{"usbstorage",DC_TRANSPORT_USBSTORAGE}, {"usbstorage",DC_TRANSPORT_USBSTORAGE},
}; };
@ -412,41 +399,6 @@ dctool_file_read (const char *filename)
return buffer; return buffer;
} }
static dc_status_t
dctool_usb_open (dc_iostream_t **out, dc_context_t *context, dc_descriptor_t *descriptor)
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
// Discover the usb device.
dc_iterator_t *iterator = NULL;
dc_usb_device_t *device = NULL;
dc_usb_iterator_new (&iterator, context, descriptor);
while (dc_iterator_next (iterator, &device) == DC_STATUS_SUCCESS) {
break;
}
dc_iterator_free (iterator);
if (device == NULL) {
ERROR ("No dive computer found.");
status = DC_STATUS_NODEVICE;
goto cleanup;
}
// Open the usb device.
status = dc_usb_open (&iostream, context, device);
if (status != DC_STATUS_SUCCESS) {
ERROR ("Failed to open the usb device.");
goto cleanup;
}
*out = iostream;
cleanup:
dc_usb_device_free (device);
return status;
}
static dc_status_t static dc_status_t
dctool_usbhid_open (dc_iostream_t **out, dc_context_t *context, dc_descriptor_t *descriptor) dctool_usbhid_open (dc_iostream_t **out, dc_context_t *context, dc_descriptor_t *descriptor)
{ {
@ -581,18 +533,16 @@ dctool_iostream_open (dc_iostream_t **iostream, dc_context_t *context, dc_descri
case DC_TRANSPORT_SERIAL: case DC_TRANSPORT_SERIAL:
return dc_serial_open (iostream, context, devname); return dc_serial_open (iostream, context, devname);
case DC_TRANSPORT_USB: case DC_TRANSPORT_USB:
return dctool_usb_open(iostream, context, descriptor); return DC_STATUS_SUCCESS;
case DC_TRANSPORT_USBHID: case DC_TRANSPORT_USBHID:
return dctool_usbhid_open(iostream, context, descriptor); return dctool_usbhid_open(iostream, context, descriptor);
case DC_TRANSPORT_IRDA: case DC_TRANSPORT_IRDA:
return dctool_irda_open (iostream, context, descriptor, devname); return dctool_irda_open (iostream, context, descriptor, devname);
case DC_TRANSPORT_BLUETOOTH: case DC_TRANSPORT_BLUETOOTH:
return dctool_bluetooth_open (iostream, context, descriptor, devname); return dctool_bluetooth_open (iostream, context, descriptor, devname);
default:
return DC_STATUS_UNSUPPORTED;
// Not merged upstream yet
case DC_TRANSPORT_USBSTORAGE: case DC_TRANSPORT_USBSTORAGE:
return dc_usb_storage_open (iostream, context, devname); return dc_usb_storage_open (iostream, context, devname);
default:
return DC_STATUS_UNSUPPORTED;
} }
} }

View File

@ -24,12 +24,10 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -50,7 +48,7 @@
#define RESET 1 #define RESET 1
#endif #endif
#if defined(__GLIBC__) || defined(__MINGW32__) || defined(BSD) || defined(__ANDROID__) #if defined(__GLIBC__) || defined(__MINGW32__) || defined(BSD)
#define NOPERMUTATION "+" #define NOPERMUTATION "+"
#else #else
#define NOPERMUTATION "" #define NOPERMUTATION ""
@ -242,8 +240,7 @@ main (int argc, char *argv[])
} }
// Translate the help option into a command. // Translate the help option into a command.
char helpcmd[] = "help"; char *argv_help[] = {(char *) "help", NULL, NULL};
char *argv_help[] = {helpcmd, NULL, NULL};
if (help || argv[0] == NULL) { if (help || argv[0] == NULL) {
if (argv[0]) { if (argv[0]) {
argv_help[1] = argv[0]; argv_help[1] = argv[0];

View File

@ -24,11 +24,9 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -80,12 +78,20 @@ dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fing
// Create the parser. // Create the parser.
message ("Creating the parser.\n"); message ("Creating the parser.\n");
rc = dc_parser_new (&parser, divedata->device, data, size); rc = dc_parser_new (&parser, divedata->device);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error creating the parser."); ERROR ("Error creating the parser.");
goto cleanup; goto cleanup;
} }
// Register the data.
message ("Registering the data.\n");
rc = dc_parser_set_data (parser, data, size);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error registering the data.");
goto cleanup;
}
// Parse the dive data. // Parse the dive data.
message ("Parsing the dive data.\n"); message ("Parsing the dive data.\n");
rc = dctool_output_write (divedata->output, parser, data, size, fingerprint, fsize); rc = dctool_output_write (divedata->output, parser, data, size, fingerprint, fsize);

View File

@ -24,11 +24,9 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -94,7 +92,7 @@ fwupdate (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t tra
rc = hw_ostc_device_fwupdate (device, hexfile); rc = hw_ostc_device_fwupdate (device, hexfile);
break; break;
case DC_FAMILY_HW_OSTC3: case DC_FAMILY_HW_OSTC3:
rc = hw_ostc3_device_fwupdate (device, hexfile, false); rc = hw_ostc3_device_fwupdate (device, hexfile);
break; break;
case DC_FAMILY_DIVESYSTEM_IDIVE: case DC_FAMILY_DIVESYSTEM_IDIVE:
rc = divesystem_idive_device_fwupdate (device, hexfile); rc = divesystem_idive_device_fwupdate (device, hexfile);

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,11 +24,9 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -54,17 +52,17 @@ parse (dc_buffer_t *buffer, dc_context_t *context, dc_descriptor_t *descriptor,
// Create the parser. // Create the parser.
message ("Creating the parser.\n"); message ("Creating the parser.\n");
rc = dc_parser_new2 (&parser, context, descriptor, data, size); rc = dc_parser_new2 (&parser, context, descriptor, devtime, systime);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error creating the parser."); ERROR ("Error creating the parser.");
goto cleanup; goto cleanup;
} }
// Set the clock. // Register the data.
message ("Setting the clock.\n"); message ("Registering the data.\n");
rc = dc_parser_set_clock (parser, devtime, systime); rc = dc_parser_set_data (parser, data, size);
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error setting the clock."); ERROR ("Error registering the data.");
goto cleanup; goto cleanup;
} }
@ -154,7 +152,7 @@ dctool_parse_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
goto cleanup; goto cleanup;
} }
for (int i = 0; i < argc; ++i) { for (unsigned int i = 0; i < argc; ++i) {
// Read the input file. // Read the input file.
buffer = dctool_file_read (argv[i]); buffer = dctool_file_read (argv[i]);
if (buffer == NULL) { if (buffer == NULL) {

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif
@ -38,7 +36,6 @@
#include <libdivecomputer/serial.h> #include <libdivecomputer/serial.h>
#include <libdivecomputer/irda.h> #include <libdivecomputer/irda.h>
#include <libdivecomputer/bluetooth.h> #include <libdivecomputer/bluetooth.h>
#include <libdivecomputer/usb.h>
#include <libdivecomputer/usbhid.h> #include <libdivecomputer/usbhid.h>
#include "dctool.h" #include "dctool.h"
@ -62,9 +59,6 @@ scan (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transpo
case DC_TRANSPORT_BLUETOOTH: case DC_TRANSPORT_BLUETOOTH:
status = dc_bluetooth_iterator_new (&iterator, context, descriptor); status = dc_bluetooth_iterator_new (&iterator, context, descriptor);
break; break;
case DC_TRANSPORT_USB:
status = dc_usb_iterator_new (&iterator, context, descriptor);
break;
case DC_TRANSPORT_USBHID: case DC_TRANSPORT_USBHID:
status = dc_usbhid_iterator_new (&iterator, context, descriptor); status = dc_usbhid_iterator_new (&iterator, context, descriptor);
break; break;
@ -96,10 +90,6 @@ scan (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transpo
dc_bluetooth_device_get_name (device)); dc_bluetooth_device_get_name (device));
dc_bluetooth_device_free (device); dc_bluetooth_device_free (device);
break; break;
case DC_TRANSPORT_USB:
printf ("%04x:%04x\n", dc_usb_device_get_vid (device), dc_usb_device_get_pid (device));
dc_usb_device_free (device);
break;
case DC_TRANSPORT_USBHID: case DC_TRANSPORT_USBHID:
printf ("%04x:%04x\n", dc_usbhid_device_get_vid (device), dc_usbhid_device_get_pid (device)); printf ("%04x:%04x\n", dc_usbhid_device_get_vid (device), dc_usbhid_device_get_pid (device));
dc_usbhid_device_free (device); dc_usbhid_device_free (device);
@ -160,7 +150,7 @@ dctool_scan_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
// Show help message. // Show help message.
if (help) { if (help) {
dctool_command_showhelp (&dctool_scan); dctool_command_showhelp (&dctool_list);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -24,10 +24,8 @@
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>
#endif #include <stdio.h>
#ifdef HAVE_GETOPT_H #ifdef HAVE_GETOPT_H
#include <getopt.h> #include <getopt.h>
#endif #endif

View File

@ -80,7 +80,7 @@ mktemplate_datetime (char *buffer, size_t size, dc_parser_t *parser)
n = snprintf (buffer, size, "%04i%02i%02iT%02i%02i%02i", n = snprintf (buffer, size, "%04i%02i%02iT%02i%02i%02i",
datetime.year, datetime.month, datetime.day, datetime.year, datetime.month, datetime.day,
datetime.hour, datetime.minute, datetime.second); datetime.hour, datetime.minute, datetime.second);
if (n < 0 || (size_t) n >= size) if (n < 0 || n >= size)
return -1; return -1;
return n; return n;
@ -92,7 +92,7 @@ mktemplate_number (char *buffer, size_t size, unsigned int number)
int n = 0; int n = 0;
n = snprintf (buffer, size, "%04u", number); n = snprintf (buffer, size, "%04u", number);
if (n < 0 || (size_t) n >= size) if (n < 0 || n >= size)
return -1; return -1;
return n; return n;

View File

@ -90,7 +90,7 @@ convert_volume (double value, dctool_units_t units)
} }
static void static void
sample_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata) sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata)
{ {
static const char *events[] = { static const char *events[] = {
"none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter", "none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter",
@ -104,80 +104,64 @@ sample_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata
sample_data_t *sampledata = (sample_data_t *) userdata; sample_data_t *sampledata = (sample_data_t *) userdata;
unsigned int seconds = 0, milliseconds = 0;
switch (type) { switch (type) {
case DC_SAMPLE_TIME: case DC_SAMPLE_TIME:
seconds = value->time / 1000;
milliseconds = value->time % 1000;
if (sampledata->nsamples++) if (sampledata->nsamples++)
fprintf (sampledata->ostream, "</sample>\n"); fprintf (sampledata->ostream, "</sample>\n");
fprintf (sampledata->ostream, "<sample>\n"); fprintf (sampledata->ostream, "<sample>\n");
if (milliseconds) { fprintf (sampledata->ostream, " <time>%02u:%02u</time>\n", value.time / 60, value.time % 60);
fprintf (sampledata->ostream, " <time>%02u:%02u.%03u</time>\n", seconds / 60, seconds % 60, milliseconds);
} else {
fprintf (sampledata->ostream, " <time>%02u:%02u</time>\n", seconds / 60, seconds % 60);
}
break; break;
case DC_SAMPLE_DEPTH: case DC_SAMPLE_DEPTH:
fprintf (sampledata->ostream, " <depth>%.2f</depth>\n", fprintf (sampledata->ostream, " <depth>%.2f</depth>\n",
convert_depth(value->depth, sampledata->units)); convert_depth(value.depth, sampledata->units));
break; break;
case DC_SAMPLE_PRESSURE: case DC_SAMPLE_PRESSURE:
fprintf (sampledata->ostream, " <pressure tank=\"%u\">%.2f</pressure>\n", fprintf (sampledata->ostream, " <pressure tank=\"%u\">%.2f</pressure>\n",
value->pressure.tank, value.pressure.tank,
convert_pressure(value->pressure.value, sampledata->units)); convert_pressure(value.pressure.value, sampledata->units));
break; break;
case DC_SAMPLE_TEMPERATURE: case DC_SAMPLE_TEMPERATURE:
fprintf (sampledata->ostream, " <temperature>%.2f</temperature>\n", fprintf (sampledata->ostream, " <temperature>%.2f</temperature>\n",
convert_temperature(value->temperature, sampledata->units)); convert_temperature(value.temperature, sampledata->units));
break; break;
case DC_SAMPLE_EVENT: case DC_SAMPLE_EVENT:
if (value->event.type != SAMPLE_EVENT_GASCHANGE && value->event.type != SAMPLE_EVENT_GASCHANGE2) { if (value.event.type != SAMPLE_EVENT_GASCHANGE && value.event.type != SAMPLE_EVENT_GASCHANGE2) {
fprintf (sampledata->ostream, " <event type=\"%u\" time=\"%u\" flags=\"%u\" value=\"%u\">%s</event>\n", fprintf (sampledata->ostream, " <event type=\"%u\" time=\"%u\" flags=\"%u\" value=\"%u\">%s</event>\n",
value->event.type, value->event.time, value->event.flags, value->event.value, events[value->event.type]); value.event.type, value.event.time, value.event.flags, value.event.value, events[value.event.type]);
} }
break; break;
case DC_SAMPLE_RBT: case DC_SAMPLE_RBT:
fprintf (sampledata->ostream, " <rbt>%u</rbt>\n", value->rbt); fprintf (sampledata->ostream, " <rbt>%u</rbt>\n", value.rbt);
break; break;
case DC_SAMPLE_HEARTBEAT: case DC_SAMPLE_HEARTBEAT:
fprintf (sampledata->ostream, " <heartbeat>%u</heartbeat>\n", value->heartbeat); fprintf (sampledata->ostream, " <heartbeat>%u</heartbeat>\n", value.heartbeat);
break; break;
case DC_SAMPLE_BEARING: case DC_SAMPLE_BEARING:
fprintf (sampledata->ostream, " <bearing>%u</bearing>\n", value->bearing); fprintf (sampledata->ostream, " <bearing>%u</bearing>\n", value.bearing);
break; break;
case DC_SAMPLE_VENDOR: case DC_SAMPLE_VENDOR:
fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value->vendor.type, value->vendor.size); fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value.vendor.type, value.vendor.size);
for (unsigned int i = 0; i < value->vendor.size; ++i) for (unsigned int i = 0; i < value.vendor.size; ++i)
fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value->vendor.data)[i]); fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value.vendor.data)[i]);
fprintf (sampledata->ostream, "</vendor>\n"); fprintf (sampledata->ostream, "</vendor>\n");
break; break;
case DC_SAMPLE_SETPOINT: case DC_SAMPLE_SETPOINT:
fprintf (sampledata->ostream, " <setpoint>%.2f</setpoint>\n", value->setpoint); fprintf (sampledata->ostream, " <setpoint>%.2f</setpoint>\n", value.setpoint);
break; break;
case DC_SAMPLE_PPO2: case DC_SAMPLE_PPO2:
if (value->ppo2.sensor != DC_SENSOR_NONE) { fprintf (sampledata->ostream, " <ppo2>%.2f</ppo2>\n", value.ppo2);
fprintf (sampledata->ostream, " <ppo2 sensor=\"%u\">%.2f</ppo2>\n", value->ppo2.sensor, value->ppo2.value);
} else {
fprintf (sampledata->ostream, " <ppo2>%.2f</ppo2>\n", value->ppo2.value);
}
break; break;
case DC_SAMPLE_CNS: case DC_SAMPLE_CNS:
fprintf (sampledata->ostream, " <cns>%.1f</cns>\n", value->cns * 100.0); fprintf (sampledata->ostream, " <cns>%.1f</cns>\n", value.cns * 100.0);
break; break;
case DC_SAMPLE_DECO: case DC_SAMPLE_DECO:
fprintf (sampledata->ostream, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n", fprintf (sampledata->ostream, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n",
value->deco.time, value.deco.time,
convert_depth(value->deco.depth, sampledata->units), convert_depth(value.deco.depth, sampledata->units),
decostop[value->deco.type]); decostop[value.deco.type]);
if (value->deco.tts) {
fprintf (sampledata->ostream, " <tts>%u</tts>\n",
value->deco.tts);
}
break; break;
case DC_SAMPLE_GASMIX: case DC_SAMPLE_GASMIX:
fprintf (sampledata->ostream, " <gasmix>%u</gasmix>\n", value->gasmix); fprintf (sampledata->ostream, " <gasmix>%u</gasmix>\n", value.gasmix);
break; break;
default: default:
break; break;
@ -254,7 +238,7 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i %+03i:%02i</datetime>\n", fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i %+03i:%02i</datetime>\n",
dt.year, dt.month, dt.day, dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.hour, dt.minute, dt.second,
dt.timezone / 3600, (abs(dt.timezone) % 3600) / 60); dt.timezone / 3600, (dt.timezone % 3600) / 60);
} }
// Parse the divetime. // Parse the divetime.
@ -338,19 +322,11 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
"<gasmix>\n" "<gasmix>\n"
" <he>%.1f</he>\n" " <he>%.1f</he>\n"
" <o2>%.1f</o2>\n" " <o2>%.1f</o2>\n"
" <n2>%.1f</n2>\n", " <n2>%.1f</n2>\n"
"</gasmix>\n",
gasmix.helium * 100.0, gasmix.helium * 100.0,
gasmix.oxygen * 100.0, gasmix.oxygen * 100.0,
gasmix.nitrogen * 100.0); gasmix.nitrogen * 100.0);
if (gasmix.usage) {
const char *usage[] = {"none", "oxygen", "diluent", "sidemount"};
fprintf (output->ostream,
" <usage>%s</usage>\n",
usage[gasmix.usage]);
}
fprintf (output->ostream,
"</gasmix>\n");
} }
// Parse the tanks. // Parse the tanks.
@ -378,12 +354,6 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
" <gasmix>%u</gasmix>\n", " <gasmix>%u</gasmix>\n",
tank.gasmix); tank.gasmix);
} }
if (tank.usage) {
const char *usage[] = {"none", "oxygen", "diluent", "sidemount"};
fprintf (output->ostream,
" <usage>%s</usage>\n",
usage[tank.usage]);
}
if (tank.type != DC_TANKVOLUME_NONE) { if (tank.type != DC_TANKVOLUME_NONE) {
fprintf (output->ostream, fprintf (output->ostream,
" <type>%s</type>\n" " <type>%s</type>\n"
@ -416,30 +386,6 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
names[divemode]); names[divemode]);
} }
// Parse the deco model.
message ("Parsing the deco model.\n");
dc_decomodel_t decomodel = {DC_DECOMODEL_NONE};
status = dc_parser_get_field (parser, DC_FIELD_DECOMODEL, 0, &decomodel);
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
ERROR ("Error parsing the deco model.");
goto cleanup;
}
if (status != DC_STATUS_UNSUPPORTED) {
const char *names[] = {"none", "buhlmann", "vpm", "rgbm", "dciem"};
fprintf (output->ostream, "<decomodel>%s</decomodel>\n",
names[decomodel.type]);
if (decomodel.type == DC_DECOMODEL_BUHLMANN &&
(decomodel.params.gf.low != 0 || decomodel.params.gf.high != 0)) {
fprintf (output->ostream, "<gf>%u/%u</gf>\n",
decomodel.params.gf.low, decomodel.params.gf.high);
}
if (decomodel.conservatism) {
fprintf (output->ostream, "<conservatism>%d</conservatism>\n",
decomodel.conservatism);
}
}
// Parse the salinity. // Parse the salinity.
message ("Parsing the salinity.\n"); message ("Parsing the salinity.\n");
dc_salinity_t salinity = {DC_WATER_FRESH, 0.0}; dc_salinity_t salinity = {DC_WATER_FRESH, 0.0};
@ -450,14 +396,8 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
} }
if (status != DC_STATUS_UNSUPPORTED) { if (status != DC_STATUS_UNSUPPORTED) {
const char *names[] = {"fresh", "salt"}; fprintf (output->ostream, "<salinity type=\"%u\">%.1f</salinity>\n",
if (salinity.density) { salinity.type, salinity.density);
fprintf (output->ostream, "<salinity density=\"%.1f\">%s</salinity>\n",
salinity.density, names[salinity.type]);
} else {
fprintf (output->ostream, "<salinity>%s</salinity>\n",
names[salinity.type]);
}
} }
// Parse the atmospheric pressure. // Parse the atmospheric pressure.

View File

@ -26,12 +26,6 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#ifdef _MSC_VER
#define snprintf _snprintf
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
#define FUNCTION __func__ #define FUNCTION __func__
#else #else

View File

@ -12,7 +12,6 @@ libdivecomputer_HEADERS = \
bluetooth.h \ bluetooth.h \
ble.h \ ble.h \
irda.h \ irda.h \
usb.h \
usbhid.h \ usbhid.h \
custom.h \ custom.h \
device.h \ device.h \

View File

@ -36,6 +36,9 @@ atomics_cobalt_device_version (dc_device_t *device, unsigned char data[], unsign
dc_status_t dc_status_t
atomics_cobalt_device_set_simulation (dc_device_t *device, unsigned int simulation); atomics_cobalt_device_set_simulation (dc_device_t *device, unsigned int simulation);
dc_status_t
atomics_cobalt_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -33,21 +33,6 @@ extern "C" {
*/ */
#define DC_IOCTL_BLE_GET_NAME DC_IOCTL_IOR('b', 0, DC_IOCTL_SIZE_VARIABLE) #define DC_IOCTL_BLE_GET_NAME DC_IOCTL_IOR('b', 0, DC_IOCTL_SIZE_VARIABLE)
/**
* Get the bluetooth authentication PIN code.
*
* The data format is a NULL terminated string.
*/
#define DC_IOCTL_BLE_GET_PINCODE DC_IOCTL_IOR('b', 1, DC_IOCTL_SIZE_VARIABLE)
/**
* Get/set the bluetooth authentication access code.
*
* The data format is a variable sized byte array.
*/
#define DC_IOCTL_BLE_GET_ACCESSCODE DC_IOCTL_IOR('b', 2, DC_IOCTL_SIZE_VARIABLE)
#define DC_IOCTL_BLE_SET_ACCESSCODE DC_IOCTL_IOW('b', 2, DC_IOCTL_SIZE_VARIABLE)
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -51,9 +51,6 @@ dc_buffer_append (dc_buffer_t *buffer, const unsigned char data[], size_t size);
int int
dc_buffer_prepend (dc_buffer_t *buffer, const unsigned char data[], size_t size); dc_buffer_prepend (dc_buffer_t *buffer, const unsigned char data[], size_t size);
int
dc_buffer_insert (dc_buffer_t *buffer, size_t offset, const unsigned char data[], size_t size);
int int
dc_buffer_slice (dc_buffer_t *buffer, size_t offset, size_t size); dc_buffer_slice (dc_buffer_t *buffer, size_t offset, size_t size);

View File

@ -78,7 +78,6 @@ typedef enum dc_family_t {
DC_FAMILY_OCEANIC_VTPRO = (4 << 16), DC_FAMILY_OCEANIC_VTPRO = (4 << 16),
DC_FAMILY_OCEANIC_VEO250, DC_FAMILY_OCEANIC_VEO250,
DC_FAMILY_OCEANIC_ATOM2, DC_FAMILY_OCEANIC_ATOM2,
DC_FAMILY_PELAGIC_I330R,
/* Mares */ /* Mares */
DC_FAMILY_MARES_NEMO = (5 << 16), DC_FAMILY_MARES_NEMO = (5 << 16),
DC_FAMILY_MARES_PUCK, DC_FAMILY_MARES_PUCK,
@ -109,26 +108,10 @@ typedef enum dc_family_t {
DC_FAMILY_COCHRAN_COMMANDER = (14 << 16), DC_FAMILY_COCHRAN_COMMANDER = (14 << 16),
/* Tecdiving */ /* Tecdiving */
DC_FAMILY_TECDIVING_DIVECOMPUTEREU = (15 << 16), DC_FAMILY_TECDIVING_DIVECOMPUTEREU = (15 << 16),
/* McLean */
DC_FAMILY_MCLEAN_EXTREME = (16 << 16),
/* Liquivision */
DC_FAMILY_LIQUIVISION_LYNX = (17 << 16),
/* Sporasub */
DC_FAMILY_SPORASUB_SP2 = (18 << 16),
/* Deep Six */
DC_FAMILY_DEEPSIX_EXCURSION = (19 << 16),
/* Seac Screen */
DC_FAMILY_SEAC_SCREEN = (20 << 16),
/* Deepblu Cosmiq */
DC_FAMILY_DEEPBLU_COSMIQ = (21 << 16),
/* Oceans S1 */
DC_FAMILY_OCEANS_S1 = (22 << 16),
/* Divesoft Freedom */
DC_FAMILY_DIVESOFT_FREEDOM = (23 << 16),
// Not merged upstream yet
/* Garmin */ /* Garmin */
DC_FAMILY_GARMIN = (100 << 16), DC_FAMILY_GARMIN = (16 << 16),
/* Deepblu */
DC_FAMILY_DEEPBLU = (17 << 16),
} dc_family_t; } dc_family_t;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -22,13 +22,11 @@
#ifndef DC_DATETIME_H #ifndef DC_DATETIME_H
#define DC_DATETIME_H #define DC_DATETIME_H
#include <limits.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
#define DC_TIMEZONE_NONE INT_MIN #define DC_TIMEZONE_NONE 0x80000000
#if defined (_WIN32) && !defined (__GNUC__) #if defined (_WIN32) && !defined (__GNUC__)
typedef __int64 dc_ticks_t; typedef __int64 dc_ticks_t;

View File

@ -29,96 +29,29 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/**
* Opaque object representing a supported dive computer.
*/
typedef struct dc_descriptor_t dc_descriptor_t; typedef struct dc_descriptor_t dc_descriptor_t;
/**
* Create an iterator to enumerate the supported dive computers.
*
* @param[out] iterator A location to store the iterator.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t dc_status_t
dc_descriptor_iterator (dc_iterator_t **iterator); dc_descriptor_iterator (dc_iterator_t **iterator);
/**
* Free the device descriptor.
*
* @param[in] descriptor A valid device descriptor.
*/
void void
dc_descriptor_free (dc_descriptor_t *descriptor); dc_descriptor_free (dc_descriptor_t *descriptor);
/**
* Get the vendor name of the dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @returns The vendor name of the dive computer on success, or NULL on failure.
*/
const char * const char *
dc_descriptor_get_vendor (dc_descriptor_t *descriptor); dc_descriptor_get_vendor (dc_descriptor_t *descriptor);
/**
* Get the product name of the dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @returns The product name of the dive computer on success, or NULL on
* failure.
*/
const char * const char *
dc_descriptor_get_product (dc_descriptor_t *descriptor); dc_descriptor_get_product (dc_descriptor_t *descriptor);
/**
* Get the family type of the dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @returns The family type of the dive computer on success, or DC_FAMILY_NULL
* on failure.
*/
dc_family_t dc_family_t
dc_descriptor_get_type (dc_descriptor_t *descriptor); dc_descriptor_get_type (dc_descriptor_t *descriptor);
/**
* Get the model number of the dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @returns The model number of the dive computer on success, or zero on
* failure.
*/
unsigned int unsigned int
dc_descriptor_get_model (dc_descriptor_t *descriptor); dc_descriptor_get_model (dc_descriptor_t *descriptor);
/**
* Get all transports supported by the dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @returns A bitmask with all the transports supported by the dive computer on
* success, or DC_TRANSPORT_NONE on failure.
*/
unsigned int unsigned int
dc_descriptor_get_transports (dc_descriptor_t *descriptor); dc_descriptor_get_transports (dc_descriptor_t *descriptor);
/**
* Check if a low-level I/O device matches a supported dive computer.
*
* @param[in] descriptor A valid device descriptor.
* @param[in] transport The transport type of the I/O device.
* @param[in] userdata A pointer to a transport specific data structure:
* - DC_TRANSPORT_SERIAL: Name of the device node (string)
* - DC_TRANSPORT_USB: USB VID/PID (#dc_usb_desc_t)
* - DC_TRANSPORT_USBHID: USB VID/PID (#dc_usbhid_desc_t)
* - DC_TRANSPORT_IRDA: IrDA device name (string)
* - DC_TRANSPORT_BLUETOOTH: Bluetooth device name (string)
* - DC_TRANSPORT_BLE: Bluetooth device name (string)
* @returns Non-zero if the device matches a supported dive computer, or zero if
* there is no match.
*/
int
dc_descriptor_filter (dc_descriptor_t *descriptor, dc_transport_t transport, const void *userdata);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -22,8 +22,6 @@
#ifndef DC_HW_OSTC3_H #ifndef DC_HW_OSTC3_H
#define DC_HW_OSTC3_H #define DC_HW_OSTC3_H
#include <stdbool.h>
#include "common.h" #include "common.h"
#include "device.h" #include "device.h"
#include "datetime.h" #include "datetime.h"
@ -57,7 +55,7 @@ dc_status_t
hw_ostc3_device_config_reset (dc_device_t *abstract); hw_ostc3_device_config_reset (dc_device_t *abstract);
dc_status_t dc_status_t
hw_ostc3_device_fwupdate (dc_device_t *abstract, const char *filename, bool forceUpdate); hw_ostc3_device_fwupdate (dc_device_t *abstract, const char *filename);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -67,7 +67,6 @@ typedef enum dc_field_type_t {
DC_FIELD_TANK_COUNT, DC_FIELD_TANK_COUNT,
DC_FIELD_TANK, DC_FIELD_TANK,
DC_FIELD_DIVEMODE, DC_FIELD_DIVEMODE,
DC_FIELD_DECOMODEL,
DC_FIELD_STRING, DC_FIELD_STRING,
} dc_field_type_t; } dc_field_type_t;
@ -173,26 +172,19 @@ typedef struct dc_salinity_t {
double density; double density;
} dc_salinity_t; } dc_salinity_t;
typedef enum dc_usage_t {
DC_USAGE_NONE, // Usage not specified
DC_USAGE_OXYGEN,
DC_USAGE_DILUENT,
DC_USAGE_OPEN_CIRCUIT,
} dc_usage_t;
typedef struct dc_gasmix_t { typedef struct dc_gasmix_t {
double helium; double helium;
double oxygen; double oxygen;
double nitrogen; double nitrogen;
dc_usage_t usage;
} dc_gasmix_t; } dc_gasmix_t;
#define DC_SENSOR_NONE 0xFFFFFFFF
#define DC_GASMIX_UNKNOWN 0xFFFFFFFF #define DC_GASMIX_UNKNOWN 0xFFFFFFFF
typedef unsigned int dc_tankinfo_t; typedef unsigned int dc_tankinfo_t;
#define DC_TANKINFO_METRIC 1 #define DC_TANKINFO_METRIC 1
#define DC_TANKINFO_IMPERIAL 2 #define DC_TANKINFO_IMPERIAL 2
#define DC_TANKINFO_CC_DILUENT 4
#define DC_TANKINFO_CC_O2 8
// For backwards compatibility // For backwards compatibility
#define DC_TANKVOLUME_NONE 0 #define DC_TANKVOLUME_NONE 0
@ -222,11 +214,6 @@ typedef unsigned int dc_tankinfo_t;
* divide by 1 ATM (Vair = Vwater * Pwork / Patm). * divide by 1 ATM (Vair = Vwater * Pwork / Patm).
*/ */
typedef enum dc_tank_usage_t {
DC_TANK_USAGE_NONE,
DC_TANK_USAGE_SIDEMOUNT,
} dc_tank_usage_t;
typedef struct dc_tank_t { typedef struct dc_tank_t {
unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */ unsigned int gasmix; /* Gas mix index, or DC_GASMIX_UNKNOWN */
dc_tankinfo_t type; /* Tank type - metric/imperial and oc/cc */ dc_tankinfo_t type; /* Tank type - metric/imperial and oc/cc */
@ -234,53 +221,15 @@ typedef struct dc_tank_t {
double workpressure; /* Work pressure (bar) */ double workpressure; /* Work pressure (bar) */
double beginpressure; /* Begin pressure (bar) */ double beginpressure; /* Begin pressure (bar) */
double endpressure; /* End pressure (bar) */ double endpressure; /* End pressure (bar) */
dc_tank_usage_t usage;
} dc_tank_t; } dc_tank_t;
typedef enum dc_decomodel_type_t {
DC_DECOMODEL_NONE,
DC_DECOMODEL_BUHLMANN,
DC_DECOMODEL_VPM,
DC_DECOMODEL_RGBM,
DC_DECOMODEL_DCIEM,
} dc_decomodel_type_t;
/*
* Decompression model
*
* The type field contains the decompression algorithm.
*
* The (optional) conservatism field contains the personal adjustment
* setting of the algorithm. The exact interpretation depends on the
* dive computer, but the default value (zero) will typically correspond
* to the neutral setting, while a positive value is more conservative
* and a negative value more aggressive.
*
* The (optional) params field contains the parameters of the algorithm:
*
* DC_DECOMODEL_BUHLMANN: The Gradient Factor (GF) parameters low and
* high. For a pure Buhlmann algorithm (e.g. without GF enabled), both
* values are 100. If GF are enabled, but the actual parameter values
* are not available from the dive computer, both values are zero.
*/
typedef struct dc_decomodel_t {
dc_decomodel_type_t type;
int conservatism;
union {
struct {
unsigned int high;
unsigned int low;
} gf;
} params;
} dc_decomodel_t;
typedef struct dc_field_string_t { typedef struct dc_field_string_t {
const char *desc; const char *desc;
const char *value; const char *value;
} dc_field_string_t; } dc_field_string_t;
typedef union dc_sample_value_t { typedef union dc_sample_value_t {
unsigned int time; /* Milliseconds */ unsigned int time;
double depth; double depth;
struct { struct {
unsigned int tank; unsigned int tank;
@ -303,41 +252,31 @@ typedef union dc_sample_value_t {
const void *data; const void *data;
} vendor; } vendor;
double setpoint; double setpoint;
struct { double ppo2;
unsigned int sensor;
double value;
} ppo2;
double cns; double cns;
struct { struct {
unsigned int type; unsigned int type;
unsigned int time; unsigned int time;
double depth; double depth;
unsigned int tts;
} deco; } deco;
unsigned int gasmix; /* Gas mix index */ unsigned int gasmix; /* Gas mix index */
} dc_sample_value_t; } dc_sample_value_t;
typedef struct dc_parser_t dc_parser_t; typedef struct dc_parser_t dc_parser_t;
typedef void (*dc_sample_callback_t) (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata); typedef void (*dc_sample_callback_t) (dc_sample_type_t type, dc_sample_value_t value, void *userdata);
dc_status_t dc_status_t
dc_parser_new (dc_parser_t **parser, dc_device_t *device, const unsigned char data[], size_t size); dc_parser_new (dc_parser_t **parser, dc_device_t *device);
dc_status_t dc_status_t
dc_parser_new2 (dc_parser_t **parser, dc_context_t *context, dc_descriptor_t *descriptor, const unsigned char data[], size_t size); dc_parser_new2 (dc_parser_t **parser, dc_context_t *context, dc_descriptor_t *descriptor, unsigned int devtime, dc_ticks_t systime);
dc_family_t dc_family_t
dc_parser_get_type (dc_parser_t *parser); dc_parser_get_type (dc_parser_t *parser);
dc_status_t dc_status_t
dc_parser_set_clock (dc_parser_t *parser, unsigned int devtime, dc_ticks_t systime); dc_parser_set_data (dc_parser_t *parser, const unsigned char *data, unsigned int size);
dc_status_t
dc_parser_set_atmospheric (dc_parser_t *parser, double atmospheric);
dc_status_t
dc_parser_set_density (dc_parser_t *parser, double density);
dc_status_t dc_status_t
dc_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime); dc_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime);

View File

@ -35,6 +35,9 @@ extern "C" {
dc_status_t dc_status_t
reefnet_sensus_device_get_handshake (dc_device_t *device, unsigned char data[], unsigned int size); reefnet_sensus_device_get_handshake (dc_device_t *device, unsigned char data[], unsigned int size);
dc_status_t
reefnet_sensus_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -38,6 +38,9 @@ reefnet_sensuspro_device_get_handshake (dc_device_t *device, unsigned char data[
dc_status_t dc_status_t
reefnet_sensuspro_device_write_interval (dc_device_t *device, unsigned char interval); reefnet_sensuspro_device_write_interval (dc_device_t *device, unsigned char interval);
dc_status_t
reefnet_sensuspro_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -56,6 +56,9 @@ reefnet_sensusultra_device_write_parameter (dc_device_t *device, reefnet_sensusu
dc_status_t dc_status_t
reefnet_sensusultra_device_sense (dc_device_t *device, unsigned char data[], unsigned int size); reefnet_sensusultra_device_sense (dc_device_t *device, unsigned char data[], unsigned int size);
dc_status_t
reefnet_sensusultra_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -1,153 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2020 Jef Driesen
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
#ifndef DC_USB_H
#define DC_USB_H
#include "common.h"
#include "context.h"
#include "iostream.h"
#include "iterator.h"
#include "descriptor.h"
#include "ioctl.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Perform a USB control transfer.
*
* The parameters for the control transfer are specified in the
* #dc_usb_control_t data structure. If the control transfer requires
* additional data as in- or output, the buffer must be located
* immediately after the #dc_usb_control_t data structure, and the
* length of the buffer must be indicated in the #wLength field. The
* size of the ioctl request is the total size, including the size of
* the #dc_usb_control_t structure.
*/
#define DC_IOCTL_USB_CONTROL_READ DC_IOCTL_IOR('u', 0, DC_IOCTL_SIZE_VARIABLE)
#define DC_IOCTL_USB_CONTROL_WRITE DC_IOCTL_IOW('u', 0, DC_IOCTL_SIZE_VARIABLE)
/**
* USB control transfer.
*/
typedef struct dc_usb_control_t {
unsigned char bmRequestType;
unsigned char bRequest;
unsigned short wValue;
unsigned short wIndex;
unsigned short wLength;
} dc_usb_control_t;
/**
* Endpoint direction bits of the USB control transfer.
*/
typedef enum dc_usb_endpoint_t {
DC_USB_ENDPOINT_OUT = 0x00,
DC_USB_ENDPOINT_IN = 0x80
} dc_usb_endpoint_t;
/**
* Request type bits of the USB control transfer.
*/
typedef enum dc_usb_request_t {
DC_USB_REQUEST_STANDARD = 0x00,
DC_USB_REQUEST_CLASS = 0x20,
DC_USB_REQUEST_VENDOR = 0x40,
DC_USB_REQUEST_RESERVED = 0x60
} dc_usb_request_t;
/**
* Recipient bits of the USB control transfer.
*/
typedef enum dc_usb_recipient_t {
DC_USB_RECIPIENT_DEVICE = 0x00,
DC_USB_RECIPIENT_INTERFACE = 0x01,
DC_USB_RECIPIENT_ENDPOINT = 0x02,
DC_USB_RECIPIENT_OTHER = 0x03,
} dc_usb_recipient_t;
/**
* USB device descriptor.
*/
typedef struct dc_usb_desc_t {
unsigned short vid;
unsigned short pid;
} dc_usb_desc_t;
/**
* Opaque object representing a USB device.
*/
typedef struct dc_usb_device_t dc_usb_device_t;
/**
* Get the vendor id (VID) of the USB device.
*
* @param[in] device A valid USB device.
*/
unsigned int
dc_usb_device_get_vid (dc_usb_device_t *device);
/**
* Get the product id (PID) of the USB device.
*
* @param[in] device A valid USB device.
*/
unsigned int
dc_usb_device_get_pid (dc_usb_device_t *device);
/**
* Destroy the USB device and free all resources.
*
* @param[in] device A valid USB device.
*/
void
dc_usb_device_free(dc_usb_device_t *device);
/**
* Create an iterator to enumerate the USB devices.
*
* @param[out] iterator A location to store the iterator.
* @param[in] context A valid context object.
* @param[in] descriptor A valid device descriptor or NULL.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_usb_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open a USB connection.
*
* @param[out] iostream A location to store the USB connection.
* @param[in] context A valid context object.
* @param[in] device A valid USB device.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_usb_open (dc_iostream_t **iostream, dc_context_t *context, dc_usb_device_t *device);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_USB_H */

View File

@ -32,14 +32,6 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/**
* USB HID device descriptor.
*/
typedef struct dc_usbhid_desc_t {
unsigned short vid;
unsigned short pid;
} dc_usbhid_desc_t;
/** /**
* Opaque object representing a USB HID device. * Opaque object representing a USB HID device.
*/ */

939
msvc/libdivecomputer.vcproj Normal file
View File

@ -0,0 +1,939 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="libdivecomputer"
ProjectGUID="{CEA7215A-D6B5-4840-8086-3C854F371997}"
RootNamespace="libdivecomputer"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_AF_IRDA_H;HAVE_WS2BTH_H"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
CompileAs="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
LinkIncremental="2"
ModuleDefinitionFile="$(OutDir)/libdivecomputer.def"
GenerateDebugInformation="true"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBDIVECOMPUTER_EXPORTS;ENABLE_LOGGING;HAVE_AF_IRDA_H;HAVE_WS2BTH_H"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
CompileAs="2"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib"
LinkIncremental="1"
ModuleDefinitionFile="$(OutDir)/libdivecomputer.def"
GenerateDebugInformation="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\src\aes.c"
>
</File>
<File
RelativePath="..\src\array.c"
>
</File>
<File
RelativePath="..\src\atomics_cobalt.c"
>
</File>
<File
RelativePath="..\src\atomics_cobalt_parser.c"
>
</File>
<File
RelativePath="..\src\bluetooth.c"
>
</File>
<File
RelativePath="..\src\buffer.c"
>
</File>
<File
RelativePath="..\src\checksum.c"
>
</File>
<File
RelativePath="..\src\citizen_aqualand.c"
>
</File>
<File
RelativePath="..\src\citizen_aqualand_parser.c"
>
</File>
<File
RelativePath="..\src\cochran_commander.c"
>
</File>
<File
RelativePath="..\src\cochran_commander_parser.c"
>
</File>
<File
RelativePath="..\src\common.c"
>
</File>
<File
RelativePath="..\src\context.c"
>
</File>
<File
RelativePath="..\src\cressi_edy.c"
>
</File>
<File
RelativePath="..\src\cressi_edy_parser.c"
>
</File>
<File
RelativePath="..\src\cressi_goa.c"
>
</File>
<File
RelativePath="..\src\cressi_goa_parser.c"
>
</File>
<File
RelativePath="..\src\cressi_leonardo.c"
>
</File>
<File
RelativePath="..\src\cressi_leonardo_parser.c"
>
</File>
<File
RelativePath="..\src\custom.c"
>
</File>
<File
RelativePath="..\src\datetime.c"
>
</File>
<File
RelativePath="..\src\descriptor.c"
>
</File>
<File
RelativePath="..\src\device.c"
>
</File>
<File
RelativePath="..\src\diverite_nitekq.c"
>
</File>
<File
RelativePath="..\src\diverite_nitekq_parser.c"
>
</File>
<File
RelativePath="..\src\divesystem_idive.c"
>
</File>
<File
RelativePath="..\src\divesystem_idive_parser.c"
>
</File>
<File
RelativePath="..\src\hw_frog.c"
>
</File>
<File
RelativePath="..\src\hw_ostc.c"
>
</File>
<File
RelativePath="..\src\hw_ostc3.c"
>
</File>
<File
RelativePath="..\src\hw_ostc_parser.c"
>
</File>
<File
RelativePath="..\src\ihex.c"
>
</File>
<File
RelativePath="..\src\iostream.c"
>
</File>
<File
RelativePath="..\src\irda.c"
>
</File>
<File
RelativePath="..\src\iterator.c"
>
</File>
<File
RelativePath="..\src\mares_common.c"
>
</File>
<File
RelativePath="..\src\mares_darwin.c"
>
</File>
<File
RelativePath="..\src\mares_darwin_parser.c"
>
</File>
<File
RelativePath="..\src\mares_iconhd.c"
>
</File>
<File
RelativePath="..\src\mares_iconhd_parser.c"
>
</File>
<File
RelativePath="..\src\mares_nemo.c"
>
</File>
<File
RelativePath="..\src\mares_nemo_parser.c"
>
</File>
<File
RelativePath="..\src\mares_puck.c"
>
</File>
<File
RelativePath="..\src\oceanic_atom2.c"
>
</File>
<File
RelativePath="..\src\oceanic_atom2_parser.c"
>
</File>
<File
RelativePath="..\src\oceanic_common.c"
>
</File>
<File
RelativePath="..\src\oceanic_veo250.c"
>
</File>
<File
RelativePath="..\src\oceanic_veo250_parser.c"
>
</File>
<File
RelativePath="..\src\oceanic_vtpro.c"
>
</File>
<File
RelativePath="..\src\oceanic_vtpro_parser.c"
>
</File>
<File
RelativePath="..\src\parser.c"
>
</File>
<File
RelativePath="..\src\rbstream.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensus.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensus_parser.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensuspro.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensuspro_parser.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensusultra.c"
>
</File>
<File
RelativePath="..\src\reefnet_sensusultra_parser.c"
>
</File>
<File
RelativePath="..\src\ringbuffer.c"
>
</File>
<File
RelativePath="..\src\serial_win32.c"
>
</File>
<File
RelativePath="..\src\shearwater_common.c"
>
</File>
<File
RelativePath="..\src\shearwater_petrel.c"
>
</File>
<File
RelativePath="..\src\shearwater_predator.c"
>
</File>
<File
RelativePath="..\src\shearwater_predator_parser.c"
>
</File>
<File
RelativePath="..\src\socket.c"
>
</File>
<File
RelativePath="..\src\suunto_common.c"
>
</File>
<File
RelativePath="..\src\suunto_common2.c"
>
</File>
<File
RelativePath="..\src\suunto_d9.c"
>
</File>
<File
RelativePath="..\src\suunto_d9_parser.c"
>
</File>
<File
RelativePath="..\src\suunto_eon.c"
>
</File>
<File
RelativePath="..\src\suunto_eon_parser.c"
>
</File>
<File
RelativePath="..\src\suunto_eonsteel.c"
>
</File>
<File
RelativePath="..\src\suunto_eonsteel_parser.c"
>
</File>
<File
RelativePath="..\src\suunto_solution.c"
>
</File>
<File
RelativePath="..\src\suunto_solution_parser.c"
>
</File>
<File
RelativePath="..\src\suunto_vyper.c"
>
</File>
<File
RelativePath="..\src\suunto_vyper2.c"
>
</File>
<File
RelativePath="..\src\suunto_vyper_parser.c"
>
</File>
<File
RelativePath="..\src\tecdiving_divecomputereu.c"
>
</File>
<File
RelativePath="..\src\tecdiving_divecomputereu_parser.c"
>
</File>
<File
RelativePath="..\src\garmin.c"
>
</File>
<File
RelativePath="..\src\garmin_parser.c"
>
</File>
<File
RelativePath="..\src\deepblu.c"
>
</File>
<File
RelativePath="..\src\deepblu_parser.c"
>
</File>
<File
RelativePath="..\src\field-cache.c"
>
</File>
<File
RelativePath="..\src\timer.c"
>
</File>
<File
RelativePath="..\src\usbhid.c"
>
</File>
<File
RelativePath="..\src\uwatec_aladin.c"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse.c"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse_parser.c"
>
</File>
<File
RelativePath="..\src\uwatec_smart.c"
>
</File>
<File
RelativePath="..\src\uwatec_smart_parser.c"
>
</File>
<File
RelativePath="..\src\version.c"
>
</File>
<File
RelativePath="..\src\zeagle_n2ition3.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\src\aes.h"
>
</File>
<File
RelativePath="..\src\array.h"
>
</File>
<File
RelativePath="..\src\atomics_cobalt.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\atomics_cobalt.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\bluetooth.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\buffer.h"
>
</File>
<File
RelativePath="..\src\checksum.h"
>
</File>
<File
RelativePath="..\src\citizen_aqualand.h"
>
</File>
<File
RelativePath="..\src\cochran_commander.h"
>
</File>
<File
RelativePath="..\src\common-private.h"
>
</File>
<File
RelativePath="..\src\context-private.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\context.h"
>
</File>
<File
RelativePath="..\src\cressi_edy.h"
>
</File>
<File
RelativePath="..\src\cressi_goa.h"
>
</File>
<File
RelativePath="..\src\cressi_leonardo.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\custom.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\datetime.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\descriptor.h"
>
</File>
<File
RelativePath="..\src\device-private.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\device.h"
>
</File>
<File
RelativePath="..\src\diverite_nitekq.h"
>
</File>
<File
RelativePath="..\src\divesystem_idive.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\hw_frog.h"
>
</File>
<File
RelativePath="..\src\hw_frog.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\hw_ostc.h"
>
</File>
<File
RelativePath="..\src\hw_ostc.h"
>
</File>
<File
RelativePath="..\src\hw_ostc3.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\hw_ostc3.h"
>
</File>
<File
RelativePath="..\src\ihex.h"
>
</File>
<File
RelativePath="..\src\iostream-private.h"
>
</File>
<File
RelativePath="..\src\iostream.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\irda.h"
>
</File>
<File
RelativePath="..\src\iterator-private.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\iterator.h"
>
</File>
<File
RelativePath="..\src\mares_common.h"
>
</File>
<File
RelativePath="..\src\mares_darwin.h"
>
</File>
<File
RelativePath="..\src\mares_iconhd.h"
>
</File>
<File
RelativePath="..\src\mares_nemo.h"
>
</File>
<File
RelativePath="..\src\mares_puck.h"
>
</File>
<File
RelativePath="..\src\oceanic_atom2.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\oceanic_atom2.h"
>
</File>
<File
RelativePath="..\src\oceanic_common.h"
>
</File>
<File
RelativePath="..\src\oceanic_veo250.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\oceanic_veo250.h"
>
</File>
<File
RelativePath="..\src\oceanic_vtpro.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\oceanic_vtpro.h"
>
</File>
<File
RelativePath="..\src\parser-private.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\parser.h"
>
</File>
<File
RelativePath="..\src\platform.h"
>
</File>
<File
RelativePath="..\src\rbstream.h"
>
</File>
<File
RelativePath="..\src\reefnet_sensus.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\reefnet_sensus.h"
>
</File>
<File
RelativePath="..\src\reefnet_sensuspro.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\reefnet_sensuspro.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\reefnet_sensusultra.h"
>
</File>
<File
RelativePath="..\src\reefnet_sensusultra.h"
>
</File>
<File
RelativePath="..\src\revision.h"
>
</File>
<File
RelativePath="..\src\ringbuffer.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\serial.h"
>
</File>
<File
RelativePath="..\src\shearwater_common.h"
>
</File>
<File
RelativePath="..\src\shearwater_petrel.h"
>
</File>
<File
RelativePath="..\src\shearwater_predator.h"
>
</File>
<File
RelativePath="..\src\socket.h"
>
</File>
<File
RelativePath="..\src\suunto_common.h"
>
</File>
<File
RelativePath="..\src\suunto_common2.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\suunto_d9.h"
>
</File>
<File
RelativePath="..\src\suunto_d9.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\suunto_eon.h"
>
</File>
<File
RelativePath="..\src\suunto_eon.h"
>
</File>
<File
RelativePath="..\src\suunto_eonsteel.h"
>
</File>
<File
RelativePath="..\src\suunto_solution.h"
>
</File>
<File
RelativePath="..\src\suunto_vyper.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\suunto_vyper2.h"
>
</File>
<File
RelativePath="..\src\suunto_vyper2.h"
>
</File>
<File
RelativePath="..\src\tecdiving_divecomputereu.h"
>
</File>
<File
RelativePath="..\src\garmin.h"
>
</File>
<File
RelativePath="..\src\deepblu.h"
>
</File>
<File
RelativePath="..\src\timer.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\units.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\usbhid.h"
>
</File>
<File
RelativePath="..\src\uwatec_aladin.h"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse.h"
>
</File>
<File
RelativePath="..\src\uwatec_smart.h"
>
</File>
<File
RelativePath="..\include\libdivecomputer\version.h"
>
</File>
<File
RelativePath="..\src\zeagle_n2ition3.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath="..\src\libdivecomputer.rc"
>
</File>
<File
RelativePath="..\src\libdivecomputer.symbols"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="echo EXPORTS &gt; &quot;$(OutDir)/libdivecomputer.def&quot; &amp;&amp; type &quot;$(InputPath)&quot; &gt;&gt; &quot;$(OutDir)/libdivecomputer.def&quot;"
Outputs="$(OutDir)/libdivecomputer.def"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCustomBuildTool"
CommandLine="echo EXPORTS &gt; &quot;$(OutDir)/libdivecomputer.def&quot; &amp;&amp; type &quot;$(InputPath)&quot; &gt;&gt; &quot;$(OutDir)/libdivecomputer.def&quot;"
Outputs="$(OutDir)/libdivecomputer.def"
/>
</FileConfiguration>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -1,9 +1,9 @@
AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
AM_CFLAGS = $(LIBUSB_CFLAGS) $(LIBMTP_CFLAGS) $(HIDAPI_CFLAGS) $(BLUEZ_CFLAGS) AM_CFLAGS = $(LIBUSB_CFLAGS) $(HIDAPI_CFLAGS) $(BLUEZ_CFLAGS)
lib_LTLIBRARIES = libdivecomputer.la lib_LTLIBRARIES = libdivecomputer.la
libdivecomputer_la_LIBADD = $(LIBUSB_LIBS) $(LIBMTP_LIBS) $(HIDAPI_LIBS) $(BLUEZ_LIBS) -lm libdivecomputer_la_LIBADD = $(LIBUSB_LIBS) $(HIDAPI_LIBS) $(BLUEZ_LIBS) -lm
libdivecomputer_la_LDFLAGS = \ libdivecomputer_la_LDFLAGS = \
-version-info $(DC_VERSION_LIBTOOL) \ -version-info $(DC_VERSION_LIBTOOL) \
-no-undefined \ -no-undefined \
@ -16,7 +16,7 @@ endif
libdivecomputer_la_SOURCES = \ libdivecomputer_la_SOURCES = \
version.c \ version.c \
descriptor.c \ descriptor-private.h descriptor.c \
iostream-private.h iostream.c \ iostream-private.h iostream.c \
iterator-private.h iterator.c \ iterator-private.h iterator.c \
common-private.h common.c \ common-private.h common.c \
@ -43,7 +43,6 @@ libdivecomputer_la_SOURCES = \
oceanic_atom2.h oceanic_atom2.c oceanic_atom2_parser.c \ oceanic_atom2.h oceanic_atom2.c oceanic_atom2_parser.c \
oceanic_veo250.h oceanic_veo250.c oceanic_veo250_parser.c \ oceanic_veo250.h oceanic_veo250.c oceanic_veo250_parser.c \
oceanic_vtpro.h oceanic_vtpro.c oceanic_vtpro_parser.c \ oceanic_vtpro.h oceanic_vtpro.c oceanic_vtpro_parser.c \
pelagic_i330r.h pelagic_i330r.c \
mares_common.h mares_common.c \ mares_common.h mares_common.c \
mares_nemo.h mares_nemo.c mares_nemo_parser.c \ mares_nemo.h mares_nemo.c mares_nemo_parser.c \
mares_puck.h mares_puck.c \ mares_puck.h mares_puck.c \
@ -65,37 +64,23 @@ libdivecomputer_la_SOURCES = \
diverite_nitekq.h diverite_nitekq.c diverite_nitekq_parser.c \ diverite_nitekq.h diverite_nitekq.c diverite_nitekq_parser.c \
citizen_aqualand.h citizen_aqualand.c citizen_aqualand_parser.c \ citizen_aqualand.h citizen_aqualand.c citizen_aqualand_parser.c \
divesystem_idive.h divesystem_idive.c divesystem_idive_parser.c \ divesystem_idive.h divesystem_idive.c divesystem_idive_parser.c \
platform.h platform.c \ platform.h \
ringbuffer.h ringbuffer.c \ ringbuffer.h ringbuffer.c \
rbstream.h rbstream.c \ rbstream.h rbstream.c \
checksum.h checksum.c \ checksum.h checksum.c \
array.h array.c \ array.h array.c \
field-cache.h field-cache.c \
buffer.c \ buffer.c \
cochran_commander.h cochran_commander.c cochran_commander_parser.c \ cochran_commander.h cochran_commander.c cochran_commander_parser.c \
tecdiving_divecomputereu.h tecdiving_divecomputereu.c tecdiving_divecomputereu_parser.c \ tecdiving_divecomputereu.h tecdiving_divecomputereu.c tecdiving_divecomputereu_parser.c \
mclean_extreme.h mclean_extreme.c mclean_extreme_parser.c \ garmin.h garmin.c garmin_parser.c \
liquivision_lynx.h liquivision_lynx.c liquivision_lynx_parser.c \ deepblu.h deepblu.c deepblu_parser.c \
sporasub_sp2.h sporasub_sp2.c sporasub_sp2_parser.c \
deepsix_excursion.h deepsix_excursion.c deepsix_excursion_parser.c \
seac_screen.h seac_screen.c seac_screen_parser.c \
deepblu_cosmiq.h deepblu_cosmiq.c deepblu_cosmiq_parser.c \
oceans_s1_common.h oceans_s1_common.c \
oceans_s1.h oceans_s1.c oceans_s1_parser.c \
divesoft_freedom.h divesoft_freedom.c divesoft_freedom_parser.c \
hdlc.h hdlc.c \
packet.h packet.c \
socket.h socket.c \ socket.h socket.c \
irda.c \ irda.c \
usb.c \
usbhid.c \ usbhid.c \
bluetooth.c \ bluetooth.c \
custom.c
# Not merged upstream yet
libdivecomputer_la_SOURCES += \
usb_storage.c \ usb_storage.c \
field-cache.h field-cache.c \ custom.c
garmin.h garmin.c garmin_parser.c
if OS_WIN32 if OS_WIN32
libdivecomputer_la_SOURCES += serial_win32.c libdivecomputer_la_SOURCES += serial_win32.c
@ -113,7 +98,7 @@ libdivecomputer.exp: libdivecomputer.symbols
$(AM_V_GEN) sed -e '/^$$/d' $< > $@ $(AM_V_GEN) sed -e '/^$$/d' $< > $@
.rc.lo: .rc.lo:
$(AM_V_GEN) $(LIBTOOL) --silent --tag=CC --mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $< -o $@ $(AM_V_GEN) $(LIBTOOL) --silent --tag=CC --mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) $< -o $@
libdivecomputer.lo: revision.h libdivecomputer.lo: revision.h

View File

@ -98,7 +98,7 @@ typedef struct aes_state_t {
#if defined(CBC) && CBC #if defined(CBC) && CBC
// Initial Vector used only for CBC mode // Initial Vector used only for CBC mode
const uint8_t* Iv; uint8_t* Iv;
#endif #endif
} aes_state_t; } aes_state_t;
@ -542,7 +542,7 @@ void AES128_CBC_encrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length,
if(iv != 0) if(iv != 0)
{ {
state.Iv = iv; state.Iv = (uint8_t*)iv;
} }
for(i = 0; i < length; i += KEYLEN) for(i = 0; i < length; i += KEYLEN)
@ -584,7 +584,7 @@ void AES128_CBC_decrypt_buffer(uint8_t* output, uint8_t* input, uint32_t length,
// If iv is passed as 0, we continue to encrypt without re-setting the Iv // If iv is passed as 0, we continue to encrypt without re-setting the Iv
if(iv != 0) if(iv != 0)
{ {
state.Iv = iv; state.Iv = (uint8_t*)iv;
} }
for(i = 0; i < length; i += KEYLEN) for(i = 0; i < length; i += KEYLEN)

View File

@ -160,30 +160,6 @@ array_convert_str2num (const unsigned char data[], unsigned int size)
return value; return value;
} }
unsigned int
array_convert_bin2dec (const unsigned char data[], unsigned int size)
{
unsigned int value = 0;
for (unsigned int i = 0; i < size; ++i) {
value *= 100;
value += data[i];
}
return value;
}
unsigned int
array_convert_bcd2dec (const unsigned char data[], unsigned int size)
{
unsigned int value = 0;
for (unsigned int i = 0; i < size; ++i) {
value *= 100;
value += bcd2dec(data[i]);
}
return value;
}
unsigned int unsigned int
array_uint_be (const unsigned char data[], unsigned int n) array_uint_be (const unsigned char data[], unsigned int n)
{ {
@ -208,32 +184,6 @@ array_uint_le (const unsigned char data[], unsigned int n)
return value; return value;
} }
unsigned long long
array_uint64_be (const unsigned char data[])
{
return ((unsigned long long) data[0] << 56) |
((unsigned long long) data[1] << 48) |
((unsigned long long) data[2] << 40) |
((unsigned long long) data[3] << 32) |
((unsigned long long) data[4] << 24) |
((unsigned long long) data[5] << 16) |
((unsigned long long) data[6] << 8) |
((unsigned long long) data[7] << 0);
}
unsigned long long
array_uint64_le (const unsigned char data[])
{
return ((unsigned long long) data[0] << 0) |
((unsigned long long) data[1] << 8) |
((unsigned long long) data[2] << 16) |
((unsigned long long) data[3] << 24) |
((unsigned long long) data[4] << 32) |
((unsigned long long) data[5] << 40) |
((unsigned long long) data[6] << 48) |
((unsigned long long) data[7] << 56);
}
unsigned int unsigned int
array_uint32_be (const unsigned char data[]) array_uint32_be (const unsigned char data[])
{ {
@ -263,6 +213,17 @@ array_uint32_word_be (const unsigned char data[])
((unsigned int) data[3] << 16); ((unsigned int) data[3] << 16);
} }
void
array_uint32_le_set (unsigned char data[], const unsigned int input)
{
data[0] = input & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF;
data[3] = (input >> 24) & 0xFF;
}
unsigned int unsigned int
array_uint24_be (const unsigned char data[]) array_uint24_be (const unsigned char data[])
{ {
@ -271,6 +232,16 @@ array_uint24_be (const unsigned char data[])
((unsigned int) data[2] << 0); ((unsigned int) data[2] << 0);
} }
void
array_uint24_be_set (unsigned char data[], const unsigned int input)
{
data[0] = (input >> 16) & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = input & 0xFF;
}
unsigned int unsigned int
array_uint24_le (const unsigned char data[]) array_uint24_le (const unsigned char data[])
{ {
@ -294,124 +265,8 @@ array_uint16_le (const unsigned char data[])
((unsigned int) data[1] << 8); ((unsigned int) data[1] << 8);
} }
void
array_uint64_be_set (unsigned char data[], const unsigned long long input)
{
data[0] = (input >> 56) & 0xFF;
data[1] = (input >> 48) & 0xFF;
data[2] = (input >> 40) & 0xFF;
data[3] = (input >> 32) & 0xFF;
data[4] = (input >> 24) & 0xFF;
data[5] = (input >> 16) & 0xFF;
data[6] = (input >> 8) & 0xFF;
data[7] = (input ) & 0xFF;
}
void
array_uint64_le_set (unsigned char data[], const unsigned long long input)
{
data[0] = (input ) & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF;
data[3] = (input >> 24) & 0xFF;
data[4] = (input >> 32) & 0xFF;
data[5] = (input >> 40) & 0xFF;
data[6] = (input >> 48) & 0xFF;
data[7] = (input >> 56) & 0xFF;
}
void
array_uint32_be_set (unsigned char data[], const unsigned int input)
{
data[0] = (input >> 24) & 0xFF;
data[1] = (input >> 16) & 0xFF;
data[2] = (input >> 8) & 0xFF;
data[3] = (input ) & 0xFF;
}
void
array_uint32_le_set (unsigned char data[], const unsigned int input)
{
data[0] = (input ) & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF;
data[3] = (input >> 24) & 0xFF;
}
void
array_uint24_be_set (unsigned char data[], const unsigned int input)
{
data[0] = (input >> 16) & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = (input ) & 0xFF;
}
void
array_uint24_le_set (unsigned char data[], const unsigned int input)
{
data[0] = (input ) & 0xFF;
data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF;
}
void
array_uint16_be_set (unsigned char data[], const unsigned short input)
{
data[0] = (input >> 8) & 0xFF;
data[1] = (input ) & 0xFF;
}
void
array_uint16_le_set (unsigned char data[], const unsigned short input)
{
data[0] = (input ) & 0xFF;
data[1] = (input >> 8) & 0xFF;
}
unsigned char unsigned char
bcd2dec (unsigned char value) bcd2dec (unsigned char value)
{ {
return ((value >> 4) & 0x0f) * 10 + (value & 0x0f); return ((value >> 4) & 0x0f) * 10 + (value & 0x0f);
} }
unsigned char
dec2bcd (unsigned char value)
{
if (value >= 100)
return 0;
unsigned char hi = value / 10;
unsigned char lo = value % 10;
return (hi << 4) | lo;
}
/*
* When turning a two's-complement number with a certain number
* of bits into one with more bits, the sign bit must be repeated
* in all the extra bits.
*/
unsigned int
signextend (unsigned int value, unsigned int nbits)
{
if (nbits <= 0 || nbits > 32)
return 0;
unsigned int signbit = 1U << (nbits - 1);
unsigned int mask = signbit - 1;
if ((value & signbit) == signbit)
return value | ~mask;
else
return value & mask;
}
unsigned int
popcount (unsigned int value)
{
unsigned int count = 0;
while (value) {
value &= value - 1;
count++;
}
return count;
}

View File

@ -22,8 +22,6 @@
#ifndef ARRAY_H #ifndef ARRAY_H
#define ARRAY_H #define ARRAY_H
#define C_ARRAY_SIZE(a) (sizeof (a) / sizeof *(a))
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -54,24 +52,12 @@ array_convert_hex2bin (const unsigned char input[], unsigned int isize, unsigned
unsigned int unsigned int
array_convert_str2num (const unsigned char data[], unsigned int size); array_convert_str2num (const unsigned char data[], unsigned int size);
unsigned int
array_convert_bin2dec (const unsigned char data[], unsigned int size);
unsigned int
array_convert_bcd2dec (const unsigned char data[], unsigned int size);
unsigned int unsigned int
array_uint_be (const unsigned char data[], unsigned int n); array_uint_be (const unsigned char data[], unsigned int n);
unsigned int unsigned int
array_uint_le (const unsigned char data[], unsigned int n); array_uint_le (const unsigned char data[], unsigned int n);
unsigned long long
array_uint64_be (const unsigned char data[]);
unsigned long long
array_uint64_le (const unsigned char data[]);
unsigned int unsigned int
array_uint32_be (const unsigned char data[]); array_uint32_be (const unsigned char data[]);
@ -81,9 +67,15 @@ array_uint32_le (const unsigned char data[]);
unsigned int unsigned int
array_uint32_word_be (const unsigned char data[]); array_uint32_word_be (const unsigned char data[]);
void
array_uint32_le_set (unsigned char data[], const unsigned int input);
unsigned int unsigned int
array_uint24_be (const unsigned char data[]); array_uint24_be (const unsigned char data[]);
void
array_uint24_be_set (unsigned char data[], const unsigned int input);
unsigned int unsigned int
array_uint24_le (const unsigned char data[]); array_uint24_le (const unsigned char data[]);
@ -93,42 +85,9 @@ array_uint16_be (const unsigned char data[]);
unsigned short unsigned short
array_uint16_le (const unsigned char data[]); array_uint16_le (const unsigned char data[]);
void
array_uint64_be_set (unsigned char data[], const unsigned long long input);
void
array_uint64_le_set (unsigned char data[], const unsigned long long input);
void
array_uint32_be_set (unsigned char data[], const unsigned int input);
void
array_uint32_le_set (unsigned char data[], const unsigned int input);
void
array_uint24_be_set (unsigned char data[], const unsigned int input);
void
array_uint24_le_set (unsigned char data[], const unsigned int input);
void
array_uint16_be_set (unsigned char data[], const unsigned short input);
void
array_uint16_le_set (unsigned char data[], const unsigned short input);
unsigned char unsigned char
bcd2dec (unsigned char value); bcd2dec (unsigned char value);
unsigned char
dec2bcd (unsigned char value);
unsigned int
signextend (unsigned int value, unsigned int nbits);
unsigned int
popcount (unsigned int value);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -19,10 +19,19 @@
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <string.h> // memcmp, memcpy #include <string.h> // memcmp, memcpy
#include <stdlib.h> // malloc, free #include <stdlib.h> // malloc, free
#include <libdivecomputer/usb.h> #ifdef HAVE_LIBUSB
#ifdef _WIN32
#define NOGDI
#endif
#include <libusb.h>
#endif
#include "atomics_cobalt.h" #include "atomics_cobalt.h"
#include "context-private.h" #include "context-private.h"
@ -32,6 +41,8 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &atomics_cobalt_device_vtable) #define ISINSTANCE(device) dc_device_isinstance((device), &atomics_cobalt_device_vtable)
#define EXITCODE(rc) (rc == LIBUSB_ERROR_TIMEOUT ? DC_STATUS_TIMEOUT : DC_STATUS_IO)
#define COBALT1 0 #define COBALT1 0
#define COBALT2 2 #define COBALT2 2
@ -41,15 +52,16 @@
#define FP_OFFSET 20 #define FP_OFFSET 20
#define SZ_HEADER 228
#define SZ_MEMORY1 (29 * 64 * 1024) // Cobalt 1 #define SZ_MEMORY1 (29 * 64 * 1024) // Cobalt 1
#define SZ_MEMORY2 (41 * 64 * 1024) // Cobalt 2 #define SZ_MEMORY2 (41 * 64 * 1024) // Cobalt 2
#define SZ_VERSION 14 #define SZ_VERSION 14
typedef struct atomics_cobalt_device_t { typedef struct atomics_cobalt_device_t {
dc_device_t base; dc_device_t base;
dc_iostream_t *iostream; #ifdef HAVE_LIBUSB
libusb_context *context;
libusb_device_handle *handle;
#endif
unsigned int simulation; unsigned int simulation;
unsigned char fingerprint[6]; unsigned char fingerprint[6];
unsigned char version[SZ_VERSION]; unsigned char version[SZ_VERSION];
@ -57,6 +69,7 @@ typedef struct atomics_cobalt_device_t {
static dc_status_t atomics_cobalt_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size); static dc_status_t atomics_cobalt_device_set_fingerprint (dc_device_t *abstract, const unsigned char data[], unsigned int size);
static dc_status_t atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata); static dc_status_t atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata);
static dc_status_t atomics_cobalt_device_close (dc_device_t *abstract);
static const dc_device_vtable_t atomics_cobalt_device_vtable = { static const dc_device_vtable_t atomics_cobalt_device_vtable = {
sizeof(atomics_cobalt_device_t), sizeof(atomics_cobalt_device_t),
@ -67,19 +80,22 @@ static const dc_device_vtable_t atomics_cobalt_device_vtable = {
NULL, /* dump */ NULL, /* dump */
atomics_cobalt_device_foreach, /* foreach */ atomics_cobalt_device_foreach, /* foreach */
NULL, /* timesync */ NULL, /* timesync */
NULL /* close */ atomics_cobalt_device_close /* close */
}; };
dc_status_t dc_status_t
atomics_cobalt_device_open (dc_device_t **out, dc_context_t *context, dc_iostream_t *iostream) atomics_cobalt_device_open (dc_device_t **out, dc_context_t *context)
{ {
#ifdef HAVE_LIBUSB
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
atomics_cobalt_device_t *device = NULL; atomics_cobalt_device_t *device = NULL;
#endif
if (out == NULL) if (out == NULL)
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
#ifdef HAVE_LIBUSB
// Allocate memory. // Allocate memory.
device = (atomics_cobalt_device_t *) dc_device_allocate (context, &atomics_cobalt_device_vtable); device = (atomics_cobalt_device_t *) dc_device_allocate (context, &atomics_cobalt_device_vtable);
if (device == NULL) { if (device == NULL) {
@ -88,30 +104,67 @@ atomics_cobalt_device_open (dc_device_t **out, dc_context_t *context, dc_iostrea
} }
// Set the default values. // Set the default values.
device->iostream = iostream; device->context = NULL;
device->handle = NULL;
device->simulation = 0; device->simulation = 0;
memset (device->fingerprint, 0, sizeof (device->fingerprint)); memset (device->fingerprint, 0, sizeof (device->fingerprint));
// Set the timeout for receiving data (2000 ms). int rc = libusb_init (&device->context);
status = dc_iostream_set_timeout (device->iostream, TIMEOUT); if (rc < 0) {
if (status != DC_STATUS_SUCCESS) { ERROR (context, "Failed to initialize usb support.");
ERROR (context, "Failed to set the timeout."); status = DC_STATUS_IO;
goto error_free; goto error_free;
} }
device->handle = libusb_open_device_with_vid_pid (device->context, VID, PID);
if (device->handle == NULL) {
ERROR (context, "Failed to open the usb device.");
status = DC_STATUS_IO;
goto error_usb_exit;
}
rc = libusb_claim_interface (device->handle, 0);
if (rc < 0) {
ERROR (context, "Failed to claim the usb interface.");
status = DC_STATUS_IO;
goto error_usb_close;
}
status = atomics_cobalt_device_version ((dc_device_t *) device, device->version, sizeof (device->version)); status = atomics_cobalt_device_version ((dc_device_t *) device, device->version, sizeof (device->version));
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
ERROR (context, "Failed to identify the dive computer."); ERROR (context, "Failed to identify the dive computer.");
goto error_free; goto error_usb_close;
} }
*out = (dc_device_t*) device; *out = (dc_device_t*) device;
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
error_usb_close:
libusb_close (device->handle);
error_usb_exit:
libusb_exit (device->context);
error_free: error_free:
dc_device_deallocate ((dc_device_t *) device); dc_device_deallocate ((dc_device_t *) device);
return status; return status;
#else
return DC_STATUS_UNSUPPORTED;
#endif
}
static dc_status_t
atomics_cobalt_device_close (dc_device_t *abstract)
{
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
#ifdef HAVE_LIBUSB
libusb_release_interface(device->handle, 0);
libusb_close (device->handle);
libusb_exit (device->context);
#endif
return DC_STATUS_SUCCESS;
} }
@ -149,7 +202,6 @@ atomics_cobalt_device_set_simulation (dc_device_t *abstract, unsigned int simula
dc_status_t dc_status_t
atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size) atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsigned int size)
{ {
dc_status_t status = DC_STATUS_SUCCESS;
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
if (!ISINSTANCE (abstract)) if (!ISINSTANCE (abstract))
@ -158,31 +210,31 @@ atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsi
if (size < SZ_VERSION) if (size < SZ_VERSION)
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
#ifdef HAVE_LIBUSB
// Send the command to the dive computer. // Send the command to the dive computer.
unsigned char bRequest = 0x01; uint8_t bRequest = 0x01;
dc_usb_control_t control = { int rc = libusb_control_transfer (device->handle,
DC_USB_REQUEST_VENDOR | DC_USB_RECIPIENT_DEVICE | DC_USB_ENDPOINT_OUT, /* bmRequestType */ LIBUSB_RECIPIENT_DEVICE | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
bRequest, /* bRequest */ bRequest, 0, 0, NULL, 0, TIMEOUT);
0, /* wValue */ if (rc != LIBUSB_SUCCESS) {
0, /* wIndex */
0, /* wLength */
};
status = dc_iostream_ioctl (device->iostream, DC_IOCTL_USB_CONTROL_WRITE, &control, sizeof(control));
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the command."); ERROR (abstract->context, "Failed to send the command.");
return status; return EXITCODE(rc);
} }
HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Write", &bRequest, 1);
// Receive the answer from the dive computer. // Receive the answer from the dive computer.
size_t length = 0; int length = 0;
unsigned char packet[SZ_VERSION + 2] = {0}; unsigned char packet[SZ_VERSION + 2] = {0};
status = dc_iostream_read (device->iostream, packet, sizeof(packet), &length); rc = libusb_bulk_transfer (device->handle, 0x82,
if (status != DC_STATUS_SUCCESS || length != sizeof (packet)) { packet, sizeof (packet), &length, TIMEOUT);
if (rc != LIBUSB_SUCCESS || length != sizeof (packet)) {
ERROR (abstract->context, "Failed to receive the answer."); ERROR (abstract->context, "Failed to receive the answer.");
return status; return EXITCODE(rc);
} }
HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Read", packet, length);
// Verify the checksum of the packet. // Verify the checksum of the packet.
unsigned short crc = array_uint16_le (packet + SZ_VERSION); unsigned short crc = array_uint16_le (packet + SZ_VERSION);
unsigned short ccrc = checksum_add_uint16 (packet, SZ_VERSION, 0x0); unsigned short ccrc = checksum_add_uint16 (packet, SZ_VERSION, 0x0);
@ -194,13 +246,16 @@ atomics_cobalt_device_version (dc_device_t *abstract, unsigned char data[], unsi
memcpy (data, packet, SZ_VERSION); memcpy (data, packet, SZ_VERSION);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
#else
return DC_STATUS_UNSUPPORTED;
#endif
} }
static dc_status_t static dc_status_t
atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, dc_event_progress_t *progress) atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init, dc_event_progress_t *progress)
{ {
dc_status_t status = DC_STATUS_SUCCESS; #ifdef HAVE_LIBUSB
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
if (device_is_cancelled (abstract)) if (device_is_cancelled (abstract))
@ -212,47 +267,36 @@ atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init,
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
} }
// Adjust the maximum value to take into account the two byte checksum and
// the 8 byte serial number. Those extra bytes are not stored inside the
// dive header and are added dynamically during the data transfer. Since we
// don't know the total number of dives in advance, we can't calculate the
// total number of extra bytes and adjust the maximum on the fly.
if (progress) {
progress->maximum += 2 + 8;
}
// Send the command to the dive computer. // Send the command to the dive computer.
unsigned char bRequest = 0; uint8_t bRequest = 0;
if (device->simulation) if (device->simulation)
bRequest = init ? 0x02 : 0x03; bRequest = init ? 0x02 : 0x03;
else else
bRequest = init ? 0x09 : 0x0A; bRequest = init ? 0x09 : 0x0A;
int rc = libusb_control_transfer (device->handle,
dc_usb_control_t control = { LIBUSB_RECIPIENT_DEVICE | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_ENDPOINT_OUT,
DC_USB_REQUEST_VENDOR | DC_USB_RECIPIENT_DEVICE | DC_USB_ENDPOINT_OUT, /* bmRequestType */ bRequest, 0, 0, NULL, 0, TIMEOUT);
bRequest, /* bRequest */ if (rc != LIBUSB_SUCCESS) {
0, /* wValue */
0, /* wIndex */
0, /* wLength */
};
status = dc_iostream_ioctl (device->iostream, DC_IOCTL_USB_CONTROL_WRITE, &control, sizeof(control));
if (status != DC_STATUS_SUCCESS) {
ERROR (abstract->context, "Failed to send the command."); ERROR (abstract->context, "Failed to send the command.");
return status; return EXITCODE(rc);
} }
HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Write", &bRequest, 1);
unsigned int nbytes = 0; unsigned int nbytes = 0;
while (1) { while (1) {
// Receive the answer from the dive computer. // Receive the answer from the dive computer.
size_t length = 0; int length = 0;
unsigned char packet[8 * 1024] = {0}; unsigned char packet[8 * 1024] = {0};
status = dc_iostream_read (device->iostream, packet, sizeof(packet), &length); rc = libusb_bulk_transfer (device->handle, 0x82,
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_TIMEOUT) { packet, sizeof (packet), &length, TIMEOUT);
if (rc != LIBUSB_SUCCESS && rc != LIBUSB_ERROR_TIMEOUT) {
ERROR (abstract->context, "Failed to receive the answer."); ERROR (abstract->context, "Failed to receive the answer.");
return status; return EXITCODE(rc);
} }
HEXDUMP (abstract->context, DC_LOGLEVEL_INFO, "Read", packet, length);
// Update and emit a progress event. // Update and emit a progress event.
if (progress) { if (progress) {
progress->current += length; progress->current += length;
@ -299,6 +343,9 @@ atomics_cobalt_read_dive (dc_device_t *abstract, dc_buffer_t *buffer, int init,
dc_buffer_slice (buffer, 0, nbytes - 2); dc_buffer_slice (buffer, 0, nbytes - 2);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
#else
return DC_STATUS_UNSUPPORTED;
#endif
} }
@ -349,12 +396,6 @@ atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }
if (size < SZ_HEADER) {
ERROR (abstract->context, "Dive header is too small (%u).", size);
dc_buffer_free (buffer);
return DC_STATUS_DATAFORMAT;
}
if (memcmp (data + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0) { if (memcmp (data + FP_OFFSET, device->fingerprint, sizeof (device->fingerprint)) == 0) {
dc_buffer_free (buffer); dc_buffer_free (buffer);
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
@ -365,6 +406,12 @@ atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }
// Adjust the maximum value to take into account the two checksum bytes
// for the next dive. Since we don't know the total number of dives in
// advance, we can't calculate the total number of checksum bytes and
// adjust the maximum on the fly.
progress.maximum += 2;
ndives++; ndives++;
} }

View File

@ -23,7 +23,6 @@
#define ATOMICS_COBALT_H #define ATOMICS_COBALT_H
#include <libdivecomputer/context.h> #include <libdivecomputer/context.h>
#include <libdivecomputer/iostream.h>
#include <libdivecomputer/device.h> #include <libdivecomputer/device.h>
#include <libdivecomputer/parser.h> #include <libdivecomputer/parser.h>
#include <libdivecomputer/atomics_cobalt.h> #include <libdivecomputer/atomics_cobalt.h>
@ -33,10 +32,10 @@ extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
dc_status_t dc_status_t
atomics_cobalt_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream); atomics_cobalt_device_open (dc_device_t **device, dc_context_t *context);
dc_status_t dc_status_t
atomics_cobalt_parser_create (dc_parser_t **parser, dc_context_t *context, const unsigned char data[], size_t size); atomics_cobalt_parser_create (dc_parser_t **parser, dc_context_t *context);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -46,10 +46,11 @@ typedef struct atomics_cobalt_parser_t atomics_cobalt_parser_t;
struct atomics_cobalt_parser_t { struct atomics_cobalt_parser_t {
dc_parser_t base; dc_parser_t base;
// Depth calibration. // Depth calibration.
double atmospheric;
double hydrostatic; double hydrostatic;
}; };
static dc_status_t atomics_cobalt_parser_set_density (dc_parser_t *abstract, double density); static dc_status_t atomics_cobalt_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size);
static dc_status_t atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); static dc_status_t atomics_cobalt_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime);
static dc_status_t atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); static dc_status_t atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value);
static dc_status_t atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); static dc_status_t atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata);
@ -57,9 +58,7 @@ static dc_status_t atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract,
static const dc_parser_vtable_t atomics_cobalt_parser_vtable = { static const dc_parser_vtable_t atomics_cobalt_parser_vtable = {
sizeof(atomics_cobalt_parser_t), sizeof(atomics_cobalt_parser_t),
DC_FAMILY_ATOMICS_COBALT, DC_FAMILY_ATOMICS_COBALT,
NULL, /* set_clock */ atomics_cobalt_parser_set_data, /* set_data */
NULL, /* set_atmospheric */
atomics_cobalt_parser_set_density, /* set_density */
atomics_cobalt_parser_get_datetime, /* datetime */ atomics_cobalt_parser_get_datetime, /* datetime */
atomics_cobalt_parser_get_field, /* fields */ atomics_cobalt_parser_get_field, /* fields */
atomics_cobalt_parser_samples_foreach, /* samples_foreach */ atomics_cobalt_parser_samples_foreach, /* samples_foreach */
@ -68,7 +67,7 @@ static const dc_parser_vtable_t atomics_cobalt_parser_vtable = {
dc_status_t dc_status_t
atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context, const unsigned char data[], size_t size) atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context)
{ {
atomics_cobalt_parser_t *parser = NULL; atomics_cobalt_parser_t *parser = NULL;
@ -76,14 +75,15 @@ atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context, const un
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
// Allocate memory. // Allocate memory.
parser = (atomics_cobalt_parser_t *) dc_parser_allocate (context, &atomics_cobalt_parser_vtable, data, size); parser = (atomics_cobalt_parser_t *) dc_parser_allocate (context, &atomics_cobalt_parser_vtable);
if (parser == NULL) { if (parser == NULL) {
ERROR (context, "Failed to allocate memory."); ERROR (context, "Failed to allocate memory.");
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
} }
// Set the default values. // Set the default values.
parser->hydrostatic = DEF_DENSITY_SALT * GRAVITY; parser->atmospheric = 0.0;
parser->hydrostatic = 1025.0 * GRAVITY;
*out = (dc_parser_t*) parser; *out = (dc_parser_t*) parser;
@ -92,11 +92,22 @@ atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context, const un
static dc_status_t static dc_status_t
atomics_cobalt_parser_set_density (dc_parser_t *abstract, double density) atomics_cobalt_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
{ {
atomics_cobalt_parser_t *parser = (atomics_cobalt_parser_t *) abstract; return DC_STATUS_SUCCESS;
}
parser->hydrostatic = density * GRAVITY;
dc_status_t
atomics_cobalt_parser_set_calibration (dc_parser_t *abstract, double atmospheric, double hydrostatic)
{
atomics_cobalt_parser_t *parser = (atomics_cobalt_parser_t*) abstract;
if (!ISINSTANCE (abstract))
return DC_STATUS_INVALIDARGS;
parser->atmospheric = atmospheric;
parser->hydrostatic = hydrostatic;
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
} }
@ -140,10 +151,15 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
dc_gasmix_t *gasmix = (dc_gasmix_t *) value; dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
dc_tank_t *tank = (dc_tank_t *) value; dc_tank_t *tank = (dc_tank_t *) value;
unsigned int atmospheric = array_uint16_le (p + 0x26); double atmospheric = 0.0;
char buf[BUFLEN]; char buf[BUFLEN];
dc_field_string_t *string = (dc_field_string_t *) value; dc_field_string_t *string = (dc_field_string_t *) value;
if (parser->atmospheric)
atmospheric = parser->atmospheric;
else
atmospheric = array_uint16_le (p + 0x26) * BAR / 1000.0;
unsigned int workpressure = 0; unsigned int workpressure = 0;
if (value) { if (value) {
@ -152,14 +168,13 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
*((unsigned int *) value) = array_uint16_le (p + 0x58) * 60; *((unsigned int *) value) = array_uint16_le (p + 0x58) * 60;
break; break;
case DC_FIELD_MAXDEPTH: case DC_FIELD_MAXDEPTH:
*((double *) value) = (signed int)(array_uint16_le (p + 0x56) - atmospheric) * (BAR / 1000.0) / parser->hydrostatic; *((double *) value) = (array_uint16_le (p + 0x56) * BAR / 1000.0 - atmospheric) / parser->hydrostatic;
break; break;
case DC_FIELD_GASMIX_COUNT: case DC_FIELD_GASMIX_COUNT:
case DC_FIELD_TANK_COUNT: case DC_FIELD_TANK_COUNT:
*((unsigned int *) value) = p[0x2a]; *((unsigned int *) value) = p[0x2a];
break; break;
case DC_FIELD_GASMIX: case DC_FIELD_GASMIX:
gasmix->usage = DC_USAGE_NONE;
gasmix->helium = p[SZ_HEADER + SZ_GASMIX * flags + 5] / 100.0; gasmix->helium = p[SZ_HEADER + SZ_GASMIX * flags + 5] / 100.0;
gasmix->oxygen = p[SZ_HEADER + SZ_GASMIX * flags + 4] / 100.0; gasmix->oxygen = p[SZ_HEADER + SZ_GASMIX * flags + 4] / 100.0;
gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium;
@ -191,7 +206,6 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
tank->gasmix = flags; tank->gasmix = flags;
tank->beginpressure = array_uint16_le(p + 6) * PSI / BAR; tank->beginpressure = array_uint16_le(p + 6) * PSI / BAR;
tank->endpressure = array_uint16_le(p + 14) * PSI / BAR; tank->endpressure = array_uint16_le(p + 14) * PSI / BAR;
tank->usage = DC_TANK_USAGE_NONE;
break; break;
case DC_FIELD_DIVEMODE: case DC_FIELD_DIVEMODE:
switch(p[0x24]) { switch(p[0x24]) {
@ -206,9 +220,6 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
break; break;
case DC_FIELD_ATMOSPHERIC:
*((double *) value) = atmospheric / 1000.0;
break;
case DC_FIELD_STRING: case DC_FIELD_STRING:
switch(flags) { switch(flags) {
case 0: // Serialnr case 0: // Serialnr
@ -263,7 +274,11 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
if (size < header + SZ_SEGMENT * nsegments) if (size < header + SZ_SEGMENT * nsegments)
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
unsigned int atmospheric = array_uint16_le (data + 0x26); double atmospheric = 0.0;
if (parser->atmospheric)
atmospheric = parser->atmospheric;
else
atmospheric = array_uint16_le (data + 0x26) * BAR / 1000.0;
// Previous gas mix - initialize with impossible value // Previous gas mix - initialize with impossible value
unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int gasmix_previous = 0xFFFFFFFF;
@ -289,19 +304,19 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
// Depth (1/1000 bar). // Depth (1/1000 bar).
unsigned int depth = array_uint16_le (data + offset + 0); unsigned int depth = array_uint16_le (data + offset + 0);
sample.depth = (signed int)(depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic; sample.depth = (depth * BAR / 1000.0 - atmospheric) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Pressure (1 psi). // Pressure (1 psi).
unsigned int pressure = array_uint16_le (data + offset + 2); unsigned int pressure = array_uint16_le (data + offset + 2);
sample.pressure.tank = tank; sample.pressure.tank = tank;
sample.pressure.value = pressure * PSI / BAR; sample.pressure.value = pressure * PSI / BAR;
if (callback) callback (DC_SAMPLE_PRESSURE, &sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata);
// Current gas mix // Current gas mix
unsigned int gasmix = data[offset + 4]; unsigned int gasmix = data[offset + 4];
@ -317,14 +332,14 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix_previous = gasmix; gasmix_previous = gasmix;
} }
// Temperature (1 °F). // Temperature (1 °F).
unsigned int temperature = data[offset + 8]; unsigned int temperature = data[offset + 8];
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
// violation status // violation status
sample.event.type = 0; sample.event.type = 0;
@ -334,15 +349,15 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
unsigned int violation = data[offset + 11]; unsigned int violation = data[offset + 11];
if (violation & 0x01) { if (violation & 0x01) {
sample.event.type = SAMPLE_EVENT_ASCENT; sample.event.type = SAMPLE_EVENT_ASCENT;
if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
} }
if (violation & 0x04) { if (violation & 0x04) {
sample.event.type = SAMPLE_EVENT_CEILING; sample.event.type = SAMPLE_EVENT_CEILING;
if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
} }
if (violation & 0x08) { if (violation & 0x08) {
sample.event.type = SAMPLE_EVENT_PO2; sample.event.type = SAMPLE_EVENT_PO2;
if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
} }
// NDL & deco // NDL & deco
@ -357,8 +372,7 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
sample.deco.type = DC_DECO_NDL; sample.deco.type = DC_DECO_NDL;
sample.deco.time = ndl; sample.deco.time = ndl;
sample.deco.depth = 0.0; sample.deco.depth = 0.0;
sample.deco.tts = 0; if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
offset += SZ_SEGMENT; offset += SZ_SEGMENT;
} }

View File

@ -24,6 +24,7 @@
#endif #endif
#include <stdlib.h> // malloc, free #include <stdlib.h> // malloc, free
#include <stdio.h>
#include "socket.h" #include "socket.h"
@ -51,6 +52,7 @@
#include "context-private.h" #include "context-private.h"
#include "iostream-private.h" #include "iostream-private.h"
#include "iterator-private.h" #include "iterator-private.h"
#include "descriptor-private.h"
#include "platform.h" #include "platform.h"
#ifdef _WIN32 #ifdef _WIN32
@ -77,7 +79,7 @@ static dc_status_t dc_bluetooth_iterator_free (dc_iterator_t *iterator);
typedef struct dc_bluetooth_iterator_t { typedef struct dc_bluetooth_iterator_t {
dc_iterator_t base; dc_iterator_t base;
dc_descriptor_t *descriptor; dc_filter_t filter;
#ifdef _WIN32 #ifdef _WIN32
HANDLE hLookup; HANDLE hLookup;
#else #else
@ -229,7 +231,7 @@ dc_bluetooth_addr2str(dc_bluetooth_address_t address, char *str, size_t size)
if (str == NULL || size < DC_BLUETOOTH_SIZE) if (str == NULL || size < DC_BLUETOOTH_SIZE)
return NULL; return NULL;
int n = dc_platform_snprintf(str, size, "%02X:%02X:%02X:%02X:%02X:%02X", int n = snprintf(str, size, "%02X:%02X:%02X:%02X:%02X:%02X",
(unsigned char)((address >> 40) & 0xFF), (unsigned char)((address >> 40) & 0xFF),
(unsigned char)((address >> 32) & 0xFF), (unsigned char)((address >> 32) & 0xFF),
(unsigned char)((address >> 24) & 0xFF), (unsigned char)((address >> 24) & 0xFF),
@ -374,7 +376,7 @@ dc_bluetooth_iterator_new (dc_iterator_t **out, dc_context_t *context, dc_descri
iterator->count = ndevices; iterator->count = ndevices;
iterator->current = 0; iterator->current = 0;
#endif #endif
iterator->descriptor = descriptor; iterator->filter = dc_descriptor_get_filter (descriptor);
*out = (dc_iterator_t *) iterator; *out = (dc_iterator_t *) iterator;
@ -454,7 +456,7 @@ dc_bluetooth_iterator_next (dc_iterator_t *abstract, void *out)
INFO (abstract->context, "Discover: address=" DC_ADDRESS_FORMAT ", name=%s", INFO (abstract->context, "Discover: address=" DC_ADDRESS_FORMAT ", name=%s",
address, name ? name : ""); address, name ? name : "");
if (!dc_descriptor_filter (iterator->descriptor, DC_TRANSPORT_BLUETOOTH, name)) { if (iterator->filter && !iterator->filter (DC_TRANSPORT_BLUETOOTH, name)) {
continue; continue;
} }

View File

@ -231,72 +231,6 @@ dc_buffer_prepend (dc_buffer_t *buffer, const unsigned char data[], size_t size)
} }
int
dc_buffer_insert (dc_buffer_t *buffer, size_t offset, const unsigned char data[], size_t size)
{
if (buffer == NULL)
return 0;
if (offset > buffer->size)
return 0;
size_t head = buffer->offset;
size_t tail = buffer->capacity - (buffer->offset + buffer->size);
unsigned char *ptr = buffer->data + buffer->offset;
if (size <= head) {
if (buffer->size)
memmove (ptr - size, ptr, offset);
buffer->offset -= size;
} else if (size <= tail) {
if (buffer->size)
memmove (ptr + offset + size, ptr + offset, buffer->size - offset);
} else if (size <= tail + head) {
size_t n = buffer->size + size;
size_t available = buffer->capacity - n;
size_t tmp_offset = head > tail ? available : 0;
unsigned char *tmp = buffer->data;
if (buffer->size) {
memmove (tmp + tmp_offset, ptr, offset);
memmove (tmp + tmp_offset + offset + size, ptr + offset, buffer->size - offset);
}
buffer->offset = tmp_offset;
} else {
size_t n = buffer->size + size;
size_t capacity = dc_buffer_expand_calc (buffer, n);
size_t available = capacity - n;
size_t tmp_offset = head > tail ? available : 0;
unsigned char *tmp = (unsigned char *) malloc (capacity);
if (tmp == NULL)
return 0;
if (buffer->size) {
memcpy (tmp + tmp_offset, ptr, offset);
memcpy (tmp + tmp_offset + offset + size, ptr + offset, buffer->size - offset);
}
free (buffer->data);
buffer->data = tmp;
buffer->capacity = capacity;
buffer->offset = tmp_offset;
}
if (size)
memcpy (buffer->data + buffer->offset + offset, data, size);
buffer->size += size;
return 1;
}
int int
dc_buffer_slice (dc_buffer_t *buffer, size_t offset, size_t size) dc_buffer_slice (dc_buffer_t *buffer, size_t offset, size_t size)
{ {

View File

@ -68,13 +68,8 @@ checksum_xor_uint8 (const unsigned char data[], unsigned int size, unsigned char
} }
/*
* Polynomial: 0x1021
* RefIn: False
* RefOut: False
*/
unsigned short unsigned short
checksum_crc16_ccitt (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout) checksum_crc16_ccitt (const unsigned char data[], unsigned int size, unsigned short init)
{ {
static const unsigned short crc_ccitt_table[] = { static const unsigned short crc_ccitt_table[] = {
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
@ -115,170 +110,11 @@ checksum_crc16_ccitt (const unsigned char data[], unsigned int size, unsigned sh
for (unsigned int i = 0; i < size; ++i) for (unsigned int i = 0; i < size; ++i)
crc = (crc << 8) ^ crc_ccitt_table[(crc >> 8) ^ data[i]]; crc = (crc << 8) ^ crc_ccitt_table[(crc >> 8) ^ data[i]];
return crc ^ xorout; return crc;
} }
/*
* Polynomial: 0x1021
* RefIn: True
* RefOut: True
*/
unsigned short
checksum_crc16r_ccitt (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout)
{
static const unsigned short crc_ccitt_table[] = {
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
};
unsigned short crc = init;
for (unsigned int i = 0; i < size; ++i)
crc = (crc >> 8) ^ crc_ccitt_table[(crc ^ data[i]) & 0xff];
return crc ^ xorout;
}
/*
* Polynomial: 0x8005
* RefIn: False
* RefOut: False
*/
unsigned short
checksum_crc16_ansi (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout)
{
static const unsigned short crc_ccitt_table[] = {
0x0000, 0x8005, 0x800f, 0x000a, 0x801b, 0x001e, 0x0014, 0x8011,
0x8033, 0x0036, 0x003c, 0x8039, 0x0028, 0x802d, 0x8027, 0x0022,
0x8063, 0x0066, 0x006c, 0x8069, 0x0078, 0x807d, 0x8077, 0x0072,
0x0050, 0x8055, 0x805f, 0x005a, 0x804b, 0x004e, 0x0044, 0x8041,
0x80c3, 0x00c6, 0x00cc, 0x80c9, 0x00d8, 0x80dd, 0x80d7, 0x00d2,
0x00f0, 0x80f5, 0x80ff, 0x00fa, 0x80eb, 0x00ee, 0x00e4, 0x80e1,
0x00a0, 0x80a5, 0x80af, 0x00aa, 0x80bb, 0x00be, 0x00b4, 0x80b1,
0x8093, 0x0096, 0x009c, 0x8099, 0x0088, 0x808d, 0x8087, 0x0082,
0x8183, 0x0186, 0x018c, 0x8189, 0x0198, 0x819d, 0x8197, 0x0192,
0x01b0, 0x81b5, 0x81bf, 0x01ba, 0x81ab, 0x01ae, 0x01a4, 0x81a1,
0x01e0, 0x81e5, 0x81ef, 0x01ea, 0x81fb, 0x01fe, 0x01f4, 0x81f1,
0x81d3, 0x01d6, 0x01dc, 0x81d9, 0x01c8, 0x81cd, 0x81c7, 0x01c2,
0x0140, 0x8145, 0x814f, 0x014a, 0x815b, 0x015e, 0x0154, 0x8151,
0x8173, 0x0176, 0x017c, 0x8179, 0x0168, 0x816d, 0x8167, 0x0162,
0x8123, 0x0126, 0x012c, 0x8129, 0x0138, 0x813d, 0x8137, 0x0132,
0x0110, 0x8115, 0x811f, 0x011a, 0x810b, 0x010e, 0x0104, 0x8101,
0x8303, 0x0306, 0x030c, 0x8309, 0x0318, 0x831d, 0x8317, 0x0312,
0x0330, 0x8335, 0x833f, 0x033a, 0x832b, 0x032e, 0x0324, 0x8321,
0x0360, 0x8365, 0x836f, 0x036a, 0x837b, 0x037e, 0x0374, 0x8371,
0x8353, 0x0356, 0x035c, 0x8359, 0x0348, 0x834d, 0x8347, 0x0342,
0x03c0, 0x83c5, 0x83cf, 0x03ca, 0x83db, 0x03de, 0x03d4, 0x83d1,
0x83f3, 0x03f6, 0x03fc, 0x83f9, 0x03e8, 0x83ed, 0x83e7, 0x03e2,
0x83a3, 0x03a6, 0x03ac, 0x83a9, 0x03b8, 0x83bd, 0x83b7, 0x03b2,
0x0390, 0x8395, 0x839f, 0x039a, 0x838b, 0x038e, 0x0384, 0x8381,
0x0280, 0x8285, 0x828f, 0x028a, 0x829b, 0x029e, 0x0294, 0x8291,
0x82b3, 0x02b6, 0x02bc, 0x82b9, 0x02a8, 0x82ad, 0x82a7, 0x02a2,
0x82e3, 0x02e6, 0x02ec, 0x82e9, 0x02f8, 0x82fd, 0x82f7, 0x02f2,
0x02d0, 0x82d5, 0x82df, 0x02da, 0x82cb, 0x02ce, 0x02c4, 0x82c1,
0x8243, 0x0246, 0x024c, 0x8249, 0x0258, 0x825d, 0x8257, 0x0252,
0x0270, 0x8275, 0x827f, 0x027a, 0x826b, 0x026e, 0x0264, 0x8261,
0x0220, 0x8225, 0x822f, 0x022a, 0x823b, 0x023e, 0x0234, 0x8231,
0x8213, 0x0216, 0x021c, 0x8219, 0x0208, 0x820d, 0x8207, 0x0202
};
unsigned short crc = init;
for (unsigned int i = 0; i < size; ++i)
crc = (crc << 8) ^ crc_ccitt_table[(crc >> 8) ^ data[i]];
return crc ^ xorout;
}
/*
* Polynomial: 0x8005
* RefIn: True
* RefOut: True
*/
unsigned short
checksum_crc16r_ansi (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout)
{
static const unsigned short crc_ccitt_table[] = {
0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241,
0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440,
0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40,
0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841,
0xd801, 0x18c0, 0x1980, 0xd941, 0x1b00, 0xdbc1, 0xda81, 0x1a40,
0x1e00, 0xdec1, 0xdf81, 0x1f40, 0xdd01, 0x1dc0, 0x1c80, 0xdc41,
0x1400, 0xd4c1, 0xd581, 0x1540, 0xd701, 0x17c0, 0x1680, 0xd641,
0xd201, 0x12c0, 0x1380, 0xd341, 0x1100, 0xd1c1, 0xd081, 0x1040,
0xf001, 0x30c0, 0x3180, 0xf141, 0x3300, 0xf3c1, 0xf281, 0x3240,
0x3600, 0xf6c1, 0xf781, 0x3740, 0xf501, 0x35c0, 0x3480, 0xf441,
0x3c00, 0xfcc1, 0xfd81, 0x3d40, 0xff01, 0x3fc0, 0x3e80, 0xfe41,
0xfa01, 0x3ac0, 0x3b80, 0xfb41, 0x3900, 0xf9c1, 0xf881, 0x3840,
0x2800, 0xe8c1, 0xe981, 0x2940, 0xeb01, 0x2bc0, 0x2a80, 0xea41,
0xee01, 0x2ec0, 0x2f80, 0xef41, 0x2d00, 0xedc1, 0xec81, 0x2c40,
0xe401, 0x24c0, 0x2580, 0xe541, 0x2700, 0xe7c1, 0xe681, 0x2640,
0x2200, 0xe2c1, 0xe381, 0x2340, 0xe101, 0x21c0, 0x2080, 0xe041,
0xa001, 0x60c0, 0x6180, 0xa141, 0x6300, 0xa3c1, 0xa281, 0x6240,
0x6600, 0xa6c1, 0xa781, 0x6740, 0xa501, 0x65c0, 0x6480, 0xa441,
0x6c00, 0xacc1, 0xad81, 0x6d40, 0xaf01, 0x6fc0, 0x6e80, 0xae41,
0xaa01, 0x6ac0, 0x6b80, 0xab41, 0x6900, 0xa9c1, 0xa881, 0x6840,
0x7800, 0xb8c1, 0xb981, 0x7940, 0xbb01, 0x7bc0, 0x7a80, 0xba41,
0xbe01, 0x7ec0, 0x7f80, 0xbf41, 0x7d00, 0xbdc1, 0xbc81, 0x7c40,
0xb401, 0x74c0, 0x7580, 0xb541, 0x7700, 0xb7c1, 0xb681, 0x7640,
0x7200, 0xb2c1, 0xb381, 0x7340, 0xb101, 0x71c0, 0x7080, 0xb041,
0x5000, 0x90c1, 0x9181, 0x5140, 0x9301, 0x53c0, 0x5280, 0x9241,
0x9601, 0x56c0, 0x5780, 0x9741, 0x5500, 0x95c1, 0x9481, 0x5440,
0x9c01, 0x5cc0, 0x5d80, 0x9d41, 0x5f00, 0x9fc1, 0x9e81, 0x5e40,
0x5a00, 0x9ac1, 0x9b81, 0x5b40, 0x9901, 0x59c0, 0x5880, 0x9841,
0x8801, 0x48c0, 0x4980, 0x8941, 0x4b00, 0x8bc1, 0x8a81, 0x4a40,
0x4e00, 0x8ec1, 0x8f81, 0x4f40, 0x8d01, 0x4dc0, 0x4c80, 0x8c41,
0x4400, 0x84c1, 0x8581, 0x4540, 0x8701, 0x47c0, 0x4680, 0x8641,
0x8201, 0x42c0, 0x4380, 0x8341, 0x4100, 0x81c1, 0x8081, 0x4040
};
unsigned short crc = init;
for (unsigned int i = 0; i < size; ++i)
crc = (crc >> 8) ^ crc_ccitt_table[(crc ^ data[i]) & 0xff];
return crc ^ xorout;
}
/*
* Polynomial: 0x04C11DB7
* Init: 0xffffffff
* XorOut: 0xffffffff
* RefIn: True
* RefOut: True
*/
unsigned int unsigned int
checksum_crc32r (const unsigned char data[], unsigned int size) checksum_crc32 (const unsigned char data[], unsigned int size)
{ {
static const unsigned int crc_table[] = { static const unsigned int crc_table[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
@ -321,56 +157,3 @@ checksum_crc32r (const unsigned char data[], unsigned int size)
return crc ^ 0xffffffff; return crc ^ 0xffffffff;
} }
/*
* Polynomial: 0x04C11DB7
* Init: 0xffffffff
* XorOut: 0xffffffff
* RefIn: False
* RefOut: False
*/
unsigned int
checksum_crc32 (const unsigned char data[], unsigned int size)
{
static const unsigned int crc_table[] = {
0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC, 0x5BD4B01B, 0x569796C2, 0x52568B75,
0x6A1936C8, 0x6ED82B7F, 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A, 0x745E66CD,
0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039, 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5,
0xBE2B5B58, 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033, 0xA4AD16EA, 0xA06C0B5D,
0xD4326D90, 0xD0F37027, 0xDDB056FE, 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,
0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4, 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D,
0x34867077, 0x30476DC0, 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5, 0x2AC12072,
0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16, 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA,
0x7897AB07, 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C, 0x6211E6B5, 0x66D0FB02,
0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1, 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,
0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B, 0xBB60ADFC, 0xB6238B25, 0xB2E29692,
0x8AAD2B2F, 0x8E6C3698, 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D, 0x94EA7B2A,
0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E, 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2,
0xC6BCF05F, 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34, 0xDC3ABDED, 0xD8FBA05A,
0x690CE0EE, 0x6DCDFD59, 0x608EDB80, 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,
0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A, 0x58C1663D, 0x558240E4, 0x51435D53,
0x251D3B9E, 0x21DC2629, 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C, 0x3B5A6B9B,
0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF, 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623,
0xF12F560E, 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65, 0xEBA91BBC, 0xEF68060B,
0xD727BBB6, 0xD3E6A601, 0xDEA580D8, 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,
0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2, 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B,
0x9B3660C6, 0x9FF77D71, 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74, 0x857130C3,
0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640, 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C,
0x7B827D21, 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A, 0x61043093, 0x65C52D24,
0x119B4BE9, 0x155A565E, 0x18197087, 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,
0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D, 0x2056CD3A, 0x2D15EBE3, 0x29D4F654,
0xC5A92679, 0xC1683BCE, 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB, 0xDBEE767C,
0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18, 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4,
0x89B8FD09, 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662, 0x933EB0BB, 0x97FFAD0C,
0xAFB010B1, 0xAB710D06, 0xA6322BDF, 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4,
};
unsigned int crc = 0xffffffff;
for (unsigned int i = 0; i < size; ++i)
crc = crc_table[((crc >> 24) ^ data[i]) & 0xFF] ^ (crc << 8);
return crc ^ 0xffffffff;
}

View File

@ -39,19 +39,7 @@ unsigned char
checksum_xor_uint8 (const unsigned char data[], unsigned int size, unsigned char init); checksum_xor_uint8 (const unsigned char data[], unsigned int size, unsigned char init);
unsigned short unsigned short
checksum_crc16_ccitt (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout); checksum_crc16_ccitt (const unsigned char data[], unsigned int size, unsigned short init);
unsigned short
checksum_crc16r_ccitt (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout);
unsigned short
checksum_crc16_ansi (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout);
unsigned short
checksum_crc16r_ansi (const unsigned char data[], unsigned int size, unsigned short init, unsigned short xorout);
unsigned int
checksum_crc32r (const unsigned char data[], unsigned int size);
unsigned int unsigned int
checksum_crc32 (const unsigned char data[], unsigned int size); checksum_crc32 (const unsigned char data[], unsigned int size);

View File

@ -31,8 +31,6 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &citizen_aqualand_device_vtable) #define ISINSTANCE(device) dc_device_isinstance((device), &citizen_aqualand_device_vtable)
#define SZ_HEADER 32
typedef struct citizen_aqualand_device_t { typedef struct citizen_aqualand_device_t {
dc_device_t base; dc_device_t base;
dc_iostream_t *iostream; dc_iostream_t *iostream;
@ -202,12 +200,6 @@ citizen_aqualand_device_foreach (dc_device_t *abstract, dc_dive_callback_t callb
unsigned char *data = dc_buffer_get_data (buffer); unsigned char *data = dc_buffer_get_data (buffer);
unsigned int size = dc_buffer_get_size (buffer); unsigned int size = dc_buffer_get_size (buffer);
if (size < SZ_HEADER) {
ERROR (abstract->context, "Dive header is too small (%u).", size);
dc_buffer_free (buffer);
return DC_STATUS_DATAFORMAT;
}
if (callback && memcmp (data + 0x05, device->fingerprint, sizeof (device->fingerprint)) != 0) { if (callback && memcmp (data + 0x05, device->fingerprint, sizeof (device->fingerprint)) != 0) {
callback (data, size, data + 0x05, sizeof (device->fingerprint), userdata); callback (data, size, data + 0x05, sizeof (device->fingerprint), userdata);
} }

View File

@ -35,7 +35,7 @@ dc_status_t
citizen_aqualand_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream); citizen_aqualand_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
dc_status_t dc_status_t
citizen_aqualand_parser_create (dc_parser_t **parser, dc_context_t *context, const unsigned char data[], size_t size); citizen_aqualand_parser_create (dc_parser_t **parser, dc_context_t *context);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -36,6 +36,7 @@ typedef struct citizen_aqualand_parser_t {
dc_parser_t base; dc_parser_t base;
} citizen_aqualand_parser_t; } citizen_aqualand_parser_t;
static dc_status_t citizen_aqualand_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size);
static dc_status_t citizen_aqualand_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); static dc_status_t citizen_aqualand_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime);
static dc_status_t citizen_aqualand_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); static dc_status_t citizen_aqualand_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value);
static dc_status_t citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); static dc_status_t citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata);
@ -43,9 +44,7 @@ static dc_status_t citizen_aqualand_parser_samples_foreach (dc_parser_t *abstrac
static const dc_parser_vtable_t citizen_aqualand_parser_vtable = { static const dc_parser_vtable_t citizen_aqualand_parser_vtable = {
sizeof(citizen_aqualand_parser_t), sizeof(citizen_aqualand_parser_t),
DC_FAMILY_CITIZEN_AQUALAND, DC_FAMILY_CITIZEN_AQUALAND,
NULL, /* set_clock */ citizen_aqualand_parser_set_data, /* set_data */
NULL, /* set_atmospheric */
NULL, /* set_density */
citizen_aqualand_parser_get_datetime, /* datetime */ citizen_aqualand_parser_get_datetime, /* datetime */
citizen_aqualand_parser_get_field, /* fields */ citizen_aqualand_parser_get_field, /* fields */
citizen_aqualand_parser_samples_foreach, /* samples_foreach */ citizen_aqualand_parser_samples_foreach, /* samples_foreach */
@ -54,7 +53,7 @@ static const dc_parser_vtable_t citizen_aqualand_parser_vtable = {
dc_status_t dc_status_t
citizen_aqualand_parser_create (dc_parser_t **out, dc_context_t *context, const unsigned char data[], size_t size) citizen_aqualand_parser_create (dc_parser_t **out, dc_context_t *context)
{ {
citizen_aqualand_parser_t *parser = NULL; citizen_aqualand_parser_t *parser = NULL;
@ -62,7 +61,7 @@ citizen_aqualand_parser_create (dc_parser_t **out, dc_context_t *context, const
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
// Allocate memory. // Allocate memory.
parser = (citizen_aqualand_parser_t *) dc_parser_allocate (context, &citizen_aqualand_parser_vtable, data, size); parser = (citizen_aqualand_parser_t *) dc_parser_allocate (context, &citizen_aqualand_parser_vtable);
if (parser == NULL) { if (parser == NULL) {
ERROR (context, "Failed to allocate memory."); ERROR (context, "Failed to allocate memory.");
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
@ -74,6 +73,13 @@ citizen_aqualand_parser_create (dc_parser_t **out, dc_context_t *context, const
} }
static dc_status_t
citizen_aqualand_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
{
return DC_STATUS_SUCCESS;
}
static dc_status_t static dc_status_t
citizen_aqualand_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) citizen_aqualand_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime)
{ {
@ -232,15 +238,15 @@ citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
// Time // Time
time += interval; time += interval;
sample.time = time * 1000; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
// Depth // Depth
if (metric) if (metric)
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
else else
sample.depth = depth * FEET; sample.depth = depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Temperature // Temperature
if (time % 300 == 0) { if (time % 300 == 0) {
@ -251,7 +257,7 @@ citizen_aqualand_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callba
sample.temperature = temperature / 10.0; sample.temperature = temperature / 10.0;
else else
sample.temperature = (temperature - 32.0) * (5.0 / 9.0); sample.temperature = (temperature - 32.0) * (5.0 / 9.0);
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
} }
} }
} }

View File

@ -30,6 +30,8 @@
#include "ringbuffer.h" #include "ringbuffer.h"
#include "rbstream.h" #include "rbstream.h"
#define C_ARRAY_SIZE(array) (sizeof (array) / sizeof *(array))
#define MAXRETRIES 2 #define MAXRETRIES 2
#define COCHRAN_MODEL_COMMANDER_TM 0 #define COCHRAN_MODEL_COMMANDER_TM 0
@ -39,8 +41,6 @@
#define COCHRAN_MODEL_EMC_16 4 #define COCHRAN_MODEL_EMC_16 4
#define COCHRAN_MODEL_EMC_20 5 #define COCHRAN_MODEL_EMC_20 5
#define UNDEFINED 0xFFFFFFFF
typedef enum cochran_endian_t { typedef enum cochran_endian_t {
ENDIAN_LE, ENDIAN_LE,
ENDIAN_BE, ENDIAN_BE,
@ -57,8 +57,8 @@ typedef struct cochran_data_t {
unsigned char *logbook; unsigned char *logbook;
unsigned short int dive_count; unsigned short int dive_count;
unsigned int fp_dive_num; int fp_dive_num;
unsigned int invalid_profile_dive_num; int invalid_profile_dive_num;
unsigned int logbook_size; unsigned int logbook_size;
} cochran_data_t; } cochran_data_t;
@ -621,17 +621,18 @@ cochran_commander_find_fingerprint(cochran_commander_device_t *device, cochran_d
// We track profile ringbuffer usage to determine which dives have profile data // We track profile ringbuffer usage to determine which dives have profile data
int profile_capacity_remaining = device->layout->rb_profile_end - device->layout->rb_profile_begin; int profile_capacity_remaining = device->layout->rb_profile_end - device->layout->rb_profile_begin;
unsigned int dive_count = 0; int dive_count = -1;
data->fp_dive_num = UNDEFINED; data->fp_dive_num = -1;
// Start at end of log // Start at end of log
if (data->dive_count < device->layout->rb_logbook_entry_count) if (data->dive_count < device->layout->rb_logbook_entry_count)
dive_count = data->dive_count; dive_count = data->dive_count;
else else
dive_count = device->layout->rb_logbook_entry_count; dive_count = device->layout->rb_logbook_entry_count;
dive_count--;
unsigned int sample_read_size = 0; unsigned int sample_read_size = 0;
data->invalid_profile_dive_num = UNDEFINED; data->invalid_profile_dive_num = -1;
// Remove the pre-dive events that occur after the last dive // Remove the pre-dive events that occur after the last dive
unsigned int rb_head_ptr = 0; unsigned int rb_head_ptr = 0;
@ -675,7 +676,7 @@ cochran_commander_find_fingerprint(cochran_commander_device_t *device, cochran_d
// Loop through dives to find FP, Accumulate profile data size, // Loop through dives to find FP, Accumulate profile data size,
// and find the last dive with invalid profile // and find the last dive with invalid profile
for (unsigned int i = 0; i < dive_count; ++i) { for (unsigned int i = 0; i <= dive_count; ++i) {
unsigned int idx = (device->layout->rb_logbook_entry_count + head_dive - (i + 1)) % device->layout->rb_logbook_entry_count; unsigned int idx = (device->layout->rb_logbook_entry_count + head_dive - (i + 1)) % device->layout->rb_logbook_entry_count;
unsigned char *log_entry = data->logbook + idx * device->layout->rb_logbook_entry_size; unsigned char *log_entry = data->logbook + idx * device->layout->rb_logbook_entry_size;
@ -952,7 +953,7 @@ cochran_commander_device_foreach (dc_device_t *abstract, dc_dive_callback_t call
} }
// Change tail to dive following the fingerprint dive. // Change tail to dive following the fingerprint dive.
if (data.fp_dive_num != UNDEFINED) if (data.fp_dive_num > -1)
tail_dive = (data.fp_dive_num + 1) % layout->rb_logbook_entry_count; tail_dive = (data.fp_dive_num + 1) % layout->rb_logbook_entry_count;
// Number of dives to read // Number of dives to read

View File

@ -35,7 +35,7 @@ dc_status_t
cochran_commander_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream); cochran_commander_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
dc_status_t dc_status_t
cochran_commander_parser_create (dc_parser_t **parser, dc_context_t *context, const unsigned char data[], size_t size, unsigned int model); cochran_commander_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -29,6 +29,8 @@
#include "parser-private.h" #include "parser-private.h"
#include "array.h" #include "array.h"
#define C_ARRAY_SIZE(array) (sizeof (array) / sizeof *(array))
#define COCHRAN_MODEL_COMMANDER_TM 0 #define COCHRAN_MODEL_COMMANDER_TM 0
#define COCHRAN_MODEL_COMMANDER_PRE21000 1 #define COCHRAN_MODEL_COMMANDER_PRE21000 1
#define COCHRAN_MODEL_COMMANDER_AIR_NITROX 2 #define COCHRAN_MODEL_COMMANDER_AIR_NITROX 2
@ -99,6 +101,7 @@ typedef struct cochran_commander_parser_t {
unsigned int nevents; unsigned int nevents;
} cochran_commander_parser_t ; } cochran_commander_parser_t ;
static dc_status_t cochran_commander_parser_set_data (dc_parser_t *parser, const unsigned char *data, unsigned int size);
static dc_status_t cochran_commander_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime); static dc_status_t cochran_commander_parser_get_datetime (dc_parser_t *parser, dc_datetime_t *datetime);
static dc_status_t cochran_commander_parser_get_field (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value); static dc_status_t cochran_commander_parser_get_field (dc_parser_t *parser, dc_field_type_t type, unsigned int flags, void *value);
static dc_status_t cochran_commander_parser_samples_foreach (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata); static dc_status_t cochran_commander_parser_samples_foreach (dc_parser_t *parser, dc_sample_callback_t callback, void *userdata);
@ -106,9 +109,7 @@ static dc_status_t cochran_commander_parser_samples_foreach (dc_parser_t *parser
static const dc_parser_vtable_t cochran_commander_parser_vtable = { static const dc_parser_vtable_t cochran_commander_parser_vtable = {
sizeof(cochran_commander_parser_t), sizeof(cochran_commander_parser_t),
DC_FAMILY_COCHRAN_COMMANDER, DC_FAMILY_COCHRAN_COMMANDER,
NULL, /* set_clock */ cochran_commander_parser_set_data, /* set_data */
NULL, /* set_atmospheric */
NULL, /* set_density */
cochran_commander_parser_get_datetime, /* datetime */ cochran_commander_parser_get_datetime, /* datetime */
cochran_commander_parser_get_field, /* fields */ cochran_commander_parser_get_field, /* fields */
cochran_commander_parser_samples_foreach, /* samples_foreach */ cochran_commander_parser_samples_foreach, /* samples_foreach */
@ -313,7 +314,7 @@ cochran_commander_handle_event (cochran_commander_parser_t *parser, unsigned cha
sample.event.time = 0; sample.event.time = 0;
sample.event.value = 0; sample.event.value = 0;
sample.event.flags = event->flag; sample.event.flags = event->flag;
if (callback) callback (DC_SAMPLE_EVENT, &sample, userdata); if (callback) callback (DC_SAMPLE_EVENT, sample, userdata);
} }
} }
@ -350,7 +351,7 @@ cochran_commander_backparse(cochran_commander_parser_t *parser, const unsigned c
dc_status_t dc_status_t
cochran_commander_parser_create (dc_parser_t **out, dc_context_t *context, const unsigned char data[], size_t size, unsigned int model) cochran_commander_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model)
{ {
cochran_commander_parser_t *parser = NULL; cochran_commander_parser_t *parser = NULL;
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
@ -359,7 +360,7 @@ cochran_commander_parser_create (dc_parser_t **out, dc_context_t *context, const
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
// Allocate memory. // Allocate memory.
parser = (cochran_commander_parser_t *) dc_parser_allocate (context, &cochran_commander_parser_vtable, data, size); parser = (cochran_commander_parser_t *) dc_parser_allocate (context, &cochran_commander_parser_vtable);
if (parser == NULL) { if (parser == NULL) {
ERROR (context, "Failed to allocate memory."); ERROR (context, "Failed to allocate memory.");
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
@ -405,6 +406,13 @@ error_free:
} }
static dc_status_t
cochran_commander_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
{
return DC_STATUS_SUCCESS;
}
static dc_status_t static dc_status_t
cochran_commander_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) cochran_commander_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime)
{ {
@ -505,7 +513,6 @@ cochran_commander_parser_get_field (dc_parser_t *abstract, dc_field_type_t type,
// Gas percentages are decimal and encoded as // Gas percentages are decimal and encoded as
// highbyte = integer portion // highbyte = integer portion
// lowbyte = decimal portion, divide by 256 to get decimal value // lowbyte = decimal portion, divide by 256 to get decimal value
gasmix->usage = DC_USAGE_NONE;
gasmix->oxygen = array_uint16_le (data + layout->oxygen + 2 * flags) / 256.0 / 100; gasmix->oxygen = array_uint16_le (data + layout->oxygen + 2 * flags) / 256.0 / 100;
if (layout->helium == UNSUPPORTED) { if (layout->helium == UNSUPPORTED) {
gasmix->helium = 0; gasmix->helium = 0;
@ -570,26 +577,26 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
unsigned int temp = samples[0]; // Half degrees F unsigned int temp = samples[0]; // Half degrees F
unsigned int depth = samples[1]; // Half feet unsigned int depth = samples[1]; // Half feet
last_sample_time = sample.time = time * 1000; last_sample_time = sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
sample.depth = (depth / 2.0) * FEET; sample.depth = (depth / 2.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
sample.temperature = (temp / 2.0 - 32.0) / 1.8; sample.temperature = (temp / 2.0 - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
while (offset < size) { while (offset < size) {
const unsigned char *s = samples + offset; const unsigned char *s = samples + offset;
sample.time = time * 1000; sample.time = time;
if (last_sample_time != sample.time) { if (last_sample_time != sample.time) {
// We haven't issued this time yet. // We haven't issued this time yet.
last_sample_time = sample.time; last_sample_time = sample.time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
} }
if (*s & 0x80) { if (*s & 0x80) {
@ -607,8 +614,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.time = 60; // We don't know the duration sample.deco.time = 60; // We don't know the duration
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.tts = 0; if (callback) callback(DC_SAMPLE_DECO, sample, userdata);
if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xAD: // Increment ceiling (shallower) case 0xAD: // Increment ceiling (shallower)
deco_ceiling -= 10; // feet deco_ceiling -= 10; // feet
@ -616,8 +622,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = 60; // We don't know the duration sample.deco.time = 60; // We don't know the duration
sample.deco.tts = 0; if (callback) callback(DC_SAMPLE_DECO, sample, userdata);
if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
default: default:
cochran_commander_handle_event(parser, s[0], callback, userdata); cochran_commander_handle_event(parser, s[0], callback, userdata);
@ -630,7 +635,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
else else
temp += (*s & 0x0f); temp += (*s & 0x0f);
sample.temperature = (temp / 2.0 - 32.0) / 1.8; sample.temperature = (temp / 2.0 - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
} }
offset++; offset++;
@ -644,7 +649,7 @@ cochran_commander_parser_samples_foreach_tm (dc_parser_t *abstract, dc_sample_ca
depth += s[0] & 0x3f; depth += s[0] & 0x3f;
sample.depth = (depth / 2.0) * FEET; sample.depth = (depth / 2.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
offset++; offset++;
time += sample_interval; time += sample_interval;
@ -708,27 +713,27 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
start_depth = array_uint16_le (data + layout->start_depth) / 256.0; start_depth = array_uint16_le (data + layout->start_depth) / 256.0;
} }
last_sample_time = sample.time = time * 1000; last_sample_time = sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
sample.depth = start_depth * FEET; sample.depth = start_depth * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
sample.temperature = (data[layout->start_temp] - 32.0) / 1.8; sample.temperature = (data[layout->start_temp] - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
unsigned int last_gasmix = sample.gasmix; unsigned int last_gasmix = sample.gasmix;
while (offset < size) { while (offset < size) {
const unsigned char *s = samples + offset; const unsigned char *s = samples + offset;
sample.time = time * 1000; sample.time = time;
if (last_sample_time != sample.time) { if (last_sample_time != sample.time) {
// We haven't issued this time yet. // We haven't issued this time yet.
last_sample_time = sample.time; last_sample_time = sample.time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
} }
// If corrupt_dive end before offset // If corrupt_dive end before offset
@ -768,8 +773,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.time = (array_uint16_le(s + 3) + 1) * 60; sample.deco.time = (array_uint16_le(s + 3) + 1) * 60;
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.tts = 0; if (callback) callback(DC_SAMPLE_DECO, sample, userdata);
if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xAD: // Increment ceiling (shallower) case 0xAD: // Increment ceiling (shallower)
deco_ceiling -= 10; // feet deco_ceiling -= 10; // feet
@ -777,8 +781,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = (array_uint16_le(s + 3) + 1) * 60; sample.deco.time = (array_uint16_le(s + 3) + 1) * 60;
sample.deco.tts = 0; if (callback) callback(DC_SAMPLE_DECO, sample, userdata);
if (callback) callback(DC_SAMPLE_DECO, &sample, userdata);
break; break;
case 0xC0: // Switched to FO2 21% mode (surface) case 0xC0: // Switched to FO2 21% mode (surface)
// Event seen upon surfacing // Event seen upon surfacing
@ -787,14 +790,14 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
case 0xEF: // Switched to gas blend 2 case 0xEF: // Switched to gas blend 2
if (last_gasmix != 1) { if (last_gasmix != 1) {
sample.gasmix = 1; sample.gasmix = 1;
if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
last_gasmix = sample.gasmix; last_gasmix = sample.gasmix;
} }
break; break;
case 0xF3: // Switched to gas blend 1 case 0xF3: // Switched to gas blend 1
if (last_gasmix != 0) { if (last_gasmix != 0) {
sample.gasmix = 0; sample.gasmix = 0;
if (callback) callback(DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback(DC_SAMPLE_GASMIX, sample, userdata);
last_gasmix = sample.gasmix; last_gasmix = sample.gasmix;
} }
break; break;
@ -814,7 +817,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
depth += (s[0] & 0x3f); depth += (s[0] & 0x3f);
sample.depth = (start_depth + depth / 4.0) * FEET; sample.depth = (start_depth + depth / 4.0) * FEET;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Ascent rate is logged in the 0th sample, temp in the 1st, repeat. // Ascent rate is logged in the 0th sample, temp in the 1st, repeat.
if (time % 2 == 0) { if (time % 2 == 0) {
@ -830,7 +833,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
double temperature = s[1] / 2.0 + 20.0; double temperature = s[1] / 2.0 + 20.0;
sample.temperature = (temperature - 32.0) / 1.8; sample.temperature = (temperature - 32.0) / 1.8;
if (callback) callback (DC_SAMPLE_TEMPERATURE, &sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
} }
// Cochran EMC models store NDL and deco stop time // Cochran EMC models store NDL and deco stop time
@ -851,8 +854,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.type = DC_DECO_NDL; sample.deco.type = DC_DECO_NDL;
sample.deco.time = deco_time * 60; sample.deco.time = deco_time * 60;
sample.deco.depth = 0; sample.deco.depth = 0;
sample.deco.tts = 0; if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
break; break;
case 23: case 23:
@ -862,8 +864,7 @@ cochran_commander_parser_samples_foreach_emc (dc_parser_t *abstract, dc_sample_c
sample.deco.type = DC_DECO_DECOSTOP; sample.deco.type = DC_DECO_DECOSTOP;
sample.deco.depth = deco_ceiling * FEET; sample.deco.depth = deco_ceiling * FEET;
sample.deco.time = deco_time * 60; sample.deco.time = deco_time * 60;
sample.deco.tts = 0; if (callback) callback (DC_SAMPLE_DECO, sample, userdata);
if (callback) callback (DC_SAMPLE_DECO, &sample, userdata);
} }
break; break;
} }

View File

@ -28,8 +28,6 @@
#include <libdivecomputer/context.h> #include <libdivecomputer/context.h>
#include "platform.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -42,6 +40,12 @@ extern "C" {
#define FUNCTION __FUNCTION__ #define FUNCTION __FUNCTION__
#endif #endif
#if defined(__GNUC__)
#define ATTR_FORMAT_PRINTF(a,b) __attribute__((format(printf, a, b)))
#else
#define ATTR_FORMAT_PRINTF(a,b)
#endif
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
#define HEXDUMP(context, loglevel, prefix, data, size) dc_context_hexdump (context, loglevel, __FILE__, __LINE__, FUNCTION, prefix, data, size) #define HEXDUMP(context, loglevel, prefix, data, size) dc_context_hexdump (context, loglevel, __FILE__, __LINE__, FUNCTION, prefix, data, size)
#define SYSERROR(context, errcode) dc_context_syserror (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, FUNCTION, errcode) #define SYSERROR(context, errcode) dc_context_syserror (context, DC_LOGLEVEL_ERROR, __FILE__, __LINE__, FUNCTION, errcode)
@ -59,7 +63,7 @@ extern "C" {
#endif #endif
dc_status_t dc_status_t
dc_context_log (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *format, ...) DC_ATTR_FORMAT_PRINTF(6, 7); dc_context_log (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *format, ...) ATTR_FORMAT_PRINTF(6, 7);
dc_status_t dc_status_t
dc_context_syserror (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, int errcode); dc_context_syserror (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, int errcode);

View File

@ -25,17 +25,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include <limits.h>
#ifdef _WIN32 #ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define NOGDI #define NOGDI
#include <windows.h> #include <windows.h>
#endif #endif
#include "context-private.h" #include "context-private.h"
#include "platform.h"
#include "timer.h" #include "timer.h"
struct dc_context_t { struct dc_context_t {
@ -49,6 +47,55 @@ struct dc_context_t {
}; };
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
/*
* A wrapper for the vsnprintf function, which will always null terminate the
* string and returns a negative value if the destination buffer is too small.
*/
static int
l_vsnprintf (char *str, size_t size, const char *format, va_list ap)
{
int n;
if (size == 0)
return -1;
#ifdef _MSC_VER
/*
* The non-standard vsnprintf implementation provided by MSVC doesn't null
* terminate the string and returns a negative value if the destination
* buffer is too small.
*/
n = _vsnprintf (str, size - 1, format, ap);
if (n == size - 1 || n < 0)
str[size - 1] = 0;
#else
/*
* The C99 vsnprintf function will always null terminate the string. If the
* destination buffer is too small, the return value is the number of
* characters that would have been written if the buffer had been large
* enough.
*/
n = vsnprintf (str, size, format, ap);
if (n >= size)
n = -1;
#endif
return n;
}
static int
l_snprintf (char *str, size_t size, const char *format, ...)
{
va_list ap;
int n;
va_start (ap, format);
n = l_vsnprintf (str, size, format, ap);
va_end (ap);
return n;
}
static int static int
l_hexdump (char *str, size_t size, const unsigned char data[], size_t n) l_hexdump (char *str, size_t size, const unsigned char data[], size_t n)
{ {
@ -56,7 +103,7 @@ l_hexdump (char *str, size_t size, const unsigned char data[], size_t n)
'0', '1', '2', '3', '4', '5', '6', '7', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
if (size == 0 || size > INT_MAX) if (size == 0)
return -1; return -1;
/* The maximum number of bytes. */ /* The maximum number of bytes. */
@ -78,11 +125,11 @@ l_hexdump (char *str, size_t size, const unsigned char data[], size_t n)
/* Null terminate the hex string. */ /* Null terminate the hex string. */
str[length * 2] = 0; str[length * 2] = 0;
return (n > maxlength ? -1 : (int) (length * 2)); return (n > maxlength ? -1 : length * 2);
} }
static void static void
loghandler (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata) logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata)
{ {
const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"}; const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"};
@ -118,7 +165,7 @@ dc_context_new (dc_context_t **out)
#ifdef ENABLE_LOGGING #ifdef ENABLE_LOGGING
context->loglevel = DC_LOGLEVEL_WARNING; context->loglevel = DC_LOGLEVEL_WARNING;
context->logfunc = loghandler; context->logfunc = logfunc;
#else #else
context->loglevel = DC_LOGLEVEL_NONE; context->loglevel = DC_LOGLEVEL_NONE;
context->logfunc = NULL; context->logfunc = NULL;
@ -195,7 +242,7 @@ dc_context_log (dc_context_t *context, dc_loglevel_t loglevel, const char *file,
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
va_start (ap, format); va_start (ap, format);
dc_platform_vsnprintf (context->msg, sizeof (context->msg), format, ap); l_vsnprintf (context->msg, sizeof (context->msg), format, ap);
va_end (ap); va_end (ap);
context->logfunc (context, loglevel, file, line, function, context->msg, context->userdata); context->logfunc (context, loglevel, file, line, function, context->msg, context->userdata);
@ -261,7 +308,7 @@ dc_context_hexdump (dc_context_t *context, dc_loglevel_t loglevel, const char *f
if (context->logfunc == NULL) if (context->logfunc == NULL)
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
n = dc_platform_snprintf (context->msg, sizeof (context->msg), "%s: size=%u, data=", prefix, size); n = l_snprintf (context->msg, sizeof (context->msg), "%s: size=%u, data=", prefix, size);
if (n >= 0) { if (n >= 0) {
n = l_hexdump (context->msg + n, sizeof (context->msg) - n, data, size); n = l_hexdump (context->msg + n, sizeof (context->msg) - n, data, size);

View File

@ -38,8 +38,6 @@
#define SZ_PACKET 0x80 #define SZ_PACKET 0x80
#define SZ_PAGE (SZ_PACKET / 4) #define SZ_PAGE (SZ_PACKET / 4)
#define SZ_HEADER 32
#define IQ700 0x05 #define IQ700 0x05
#define EDY 0x08 #define EDY 0x08
@ -381,14 +379,7 @@ cressi_edy_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
} }
// Emit a device info event. return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_event_devinfo_t devinfo;
devinfo.model = device->model;
devinfo.firmware = 0;
devinfo.serial = 0;
device_event_emit (abstract, DC_EVENT_DEVINFO, &devinfo);
return device_dump_read (abstract, 0, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), SZ_PACKET); dc_buffer_get_size (buffer), SZ_PACKET);
} }
@ -524,13 +515,6 @@ cressi_edy_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
return rc; return rc;
} }
if (length < SZ_HEADER) {
ERROR (abstract->context, "Dive header is too small (%u).", length);
dc_rbstream_free (rbstream);
free (buffer);
return DC_STATUS_DATAFORMAT;
}
unsigned char *p = buffer + offset; unsigned char *p = buffer + offset;
if (memcmp (p, device->fingerprint, sizeof (device->fingerprint)) == 0) if (memcmp (p, device->fingerprint, sizeof (device->fingerprint)) == 0)

View File

@ -35,7 +35,7 @@ dc_status_t
cressi_edy_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream); cressi_edy_device_open (dc_device_t **device, dc_context_t *context, dc_iostream_t *iostream);
dc_status_t dc_status_t
cressi_edy_parser_create (dc_parser_t **parser, dc_context_t *context, const unsigned char data[], size_t size, unsigned int model); cressi_edy_parser_create (dc_parser_t **parser, dc_context_t *context, unsigned int model);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -31,8 +31,6 @@
#define IQ700 0x05 #define IQ700 0x05
#define EDY 0x08 #define EDY 0x08
#define SZ_HEADER 32
typedef struct cressi_edy_parser_t cressi_edy_parser_t; typedef struct cressi_edy_parser_t cressi_edy_parser_t;
struct cressi_edy_parser_t { struct cressi_edy_parser_t {
@ -40,6 +38,7 @@ struct cressi_edy_parser_t {
unsigned int model; unsigned int model;
}; };
static dc_status_t cressi_edy_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size);
static dc_status_t cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime); static dc_status_t cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime);
static dc_status_t cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value); static dc_status_t cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsigned int flags, void *value);
static dc_status_t cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata); static dc_status_t cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t callback, void *userdata);
@ -47,9 +46,7 @@ static dc_status_t cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_
static const dc_parser_vtable_t cressi_edy_parser_vtable = { static const dc_parser_vtable_t cressi_edy_parser_vtable = {
sizeof(cressi_edy_parser_t), sizeof(cressi_edy_parser_t),
DC_FAMILY_CRESSI_EDY, DC_FAMILY_CRESSI_EDY,
NULL, /* set_clock */ cressi_edy_parser_set_data, /* set_data */
NULL, /* set_atmospheric */
NULL, /* set_density */
cressi_edy_parser_get_datetime, /* datetime */ cressi_edy_parser_get_datetime, /* datetime */
cressi_edy_parser_get_field, /* fields */ cressi_edy_parser_get_field, /* fields */
cressi_edy_parser_samples_foreach, /* samples_foreach */ cressi_edy_parser_samples_foreach, /* samples_foreach */
@ -73,7 +70,7 @@ cressi_edy_parser_count_gasmixes (const unsigned char *data)
} }
dc_status_t dc_status_t
cressi_edy_parser_create (dc_parser_t **out, dc_context_t *context, const unsigned char data[], size_t size, unsigned int model) cressi_edy_parser_create (dc_parser_t **out, dc_context_t *context, unsigned int model)
{ {
cressi_edy_parser_t *parser = NULL; cressi_edy_parser_t *parser = NULL;
@ -81,7 +78,7 @@ cressi_edy_parser_create (dc_parser_t **out, dc_context_t *context, const unsign
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
// Allocate memory. // Allocate memory.
parser = (cressi_edy_parser_t *) dc_parser_allocate (context, &cressi_edy_parser_vtable, data, size); parser = (cressi_edy_parser_t *) dc_parser_allocate (context, &cressi_edy_parser_vtable);
if (parser == NULL) { if (parser == NULL) {
ERROR (context, "Failed to allocate memory."); ERROR (context, "Failed to allocate memory.");
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
@ -96,10 +93,17 @@ cressi_edy_parser_create (dc_parser_t **out, dc_context_t *context, const unsign
} }
static dc_status_t
cressi_edy_parser_set_data (dc_parser_t *abstract, const unsigned char *data, unsigned int size)
{
return DC_STATUS_SUCCESS;
}
static dc_status_t static dc_status_t
cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime) cressi_edy_parser_get_datetime (dc_parser_t *abstract, dc_datetime_t *datetime)
{ {
if (abstract->size < SZ_HEADER) if (abstract->size < 32)
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
const unsigned char *p = abstract->data; const unsigned char *p = abstract->data;
@ -123,7 +127,7 @@ cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign
{ {
cressi_edy_parser_t *parser = (cressi_edy_parser_t *) abstract; cressi_edy_parser_t *parser = (cressi_edy_parser_t *) abstract;
if (abstract->size < SZ_HEADER) if (abstract->size < 32)
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
const unsigned char *p = abstract->data; const unsigned char *p = abstract->data;
@ -145,7 +149,6 @@ cressi_edy_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsign
*((unsigned int *) value) = cressi_edy_parser_count_gasmixes(p); *((unsigned int *) value) = cressi_edy_parser_count_gasmixes(p);
break; break;
case DC_FIELD_GASMIX: case DC_FIELD_GASMIX:
gasmix->usage = DC_USAGE_NONE;
gasmix->helium = 0.0; gasmix->helium = 0.0;
gasmix->oxygen = bcd2dec (p[0x17 - flags]) / 100.0; gasmix->oxygen = bcd2dec (p[0x17 - flags]) / 100.0;
gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium; gasmix->nitrogen = 1.0 - gasmix->oxygen - gasmix->helium;
@ -182,7 +185,7 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
unsigned int ngasmixes = cressi_edy_parser_count_gasmixes(data); unsigned int ngasmixes = cressi_edy_parser_count_gasmixes(data);
unsigned int gasmix = 0xFFFFFFFF; unsigned int gasmix = 0xFFFFFFFF;
unsigned int offset = SZ_HEADER; unsigned int offset = 32;
while (offset + 2 <= size) { while (offset + 2 <= size) {
dc_sample_value_t sample = {0}; dc_sample_value_t sample = {0};
@ -195,13 +198,13 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
// Time (seconds). // Time (seconds).
time += interval; time += interval;
sample.time = time * 1000; sample.time = time;
if (callback) callback (DC_SAMPLE_TIME, &sample, userdata); if (callback) callback (DC_SAMPLE_TIME, sample, userdata);
// Depth (1/10 m). // Depth (1/10 m).
unsigned int depth = bcd2dec (data[offset + 0] & 0x0F) * 100 + bcd2dec (data[offset + 1]); unsigned int depth = bcd2dec (data[offset + 0] & 0x0F) * 100 + bcd2dec (data[offset + 1]);
sample.depth = depth / 10.0; sample.depth = depth / 10.0;
if (callback) callback (DC_SAMPLE_DEPTH, &sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Current gasmix // Current gasmix
if (ngasmixes) { if (ngasmixes) {
@ -214,7 +217,7 @@ cressi_edy_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t c
} }
if (idx != gasmix) { if (idx != gasmix) {
sample.gasmix = idx; sample.gasmix = idx;
if (callback) callback (DC_SAMPLE_GASMIX, &sample, userdata); if (callback) callback (DC_SAMPLE_GASMIX, sample, userdata);
gasmix = idx; gasmix = idx;
} }
} }

View File

@ -93,7 +93,7 @@ cressi_goa_device_send (cressi_goa_device_t *device, unsigned char cmd, const un
if (size) { if (size) {
memcpy (packet + 5, data, size); memcpy (packet + 5, data, size);
} }
crc = checksum_crc16_ccitt (packet + 3, size + 2, 0x000, 0x0000); crc = checksum_crc16_ccitt (packet + 3, size + 2, 0x000);
packet[5 + size + 0] = (crc ) & 0xFF; // Low packet[5 + size + 0] = (crc ) & 0xFF; // Low
packet[5 + size + 1] = (crc >> 8) & 0xFF; // High packet[5 + size + 1] = (crc >> 8) & 0xFF; // High
packet[5 + size + 2] = TRAILER; packet[5 + size + 2] = TRAILER;
@ -155,7 +155,7 @@ cressi_goa_device_receive (cressi_goa_device_t *device, unsigned char data[], un
// Verify the checksum of the packet. // Verify the checksum of the packet.
unsigned short crc = array_uint16_le (packet + length + 5); unsigned short crc = array_uint16_le (packet + length + 5);
unsigned short ccrc = checksum_crc16_ccitt (packet + 3, length + 2, 0x0000, 0x0000); unsigned short ccrc = checksum_crc16_ccitt (packet + 3, length + 2, 0x0000);
if (crc != ccrc) { if (crc != ccrc) {
ERROR (abstract->context, "Unexpected answer checksum."); ERROR (abstract->context, "Unexpected answer checksum.");
return DC_STATUS_PROTOCOL; return DC_STATUS_PROTOCOL;
@ -203,7 +203,7 @@ cressi_goa_device_download (cressi_goa_device_t *device, dc_buffer_t *buffer, dc
// Verify the checksum of the packet. // Verify the checksum of the packet.
unsigned short crc = array_uint16_le (packet + sizeof(packet) - 2); unsigned short crc = array_uint16_le (packet + sizeof(packet) - 2);
unsigned short ccrc = checksum_crc16_ccitt (packet + 3, sizeof(packet) - 5, 0x0000, 0x0000); unsigned short ccrc = checksum_crc16_ccitt (packet + 3, sizeof(packet) - 5, 0x0000);
if (crc != ccrc) { if (crc != ccrc) {
ERROR (abstract->context, "Unexpected answer checksum."); ERROR (abstract->context, "Unexpected answer checksum.");
return DC_STATUS_PROTOCOL; return DC_STATUS_PROTOCOL;
@ -485,19 +485,7 @@ cressi_goa_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, v
goto error_free_dive; goto error_free_dive;
} }
// Those 5 extra bytes contain the dive mode, which is required for if (callback && !callback(dive_data, dive_size, dive_data + FP_OFFSET - 5, sizeof(device->fingerprint), userdata))
// parsing the dive data. Therefore, insert all 5 bytes again. The
// remaining 4 bytes appear to be some 32 bit address.
if (!dc_buffer_insert (dive, 2, logbook_data + offset + 2, 5)) {
ERROR (abstract->context, "Out of memory.");
status = DC_STATUS_NOMEMORY;
goto error_free_dive;
}
dive_data = dc_buffer_get_data (dive);
dive_size = dc_buffer_get_size (dive);
if (callback && !callback(dive_data, dive_size, dive_data + FP_OFFSET, sizeof(device->fingerprint), userdata))
break; break;
} }

Some files were not shown because too many files have changed in this diff Show More