Compare commits

..

168 Commits

Author SHA1 Message Date
Dirk Hohndel
8ae735a4d7 Merge branch 'ignore-build' of https://github.com/janmulder/libdc into Subsurface-branch 2017-12-12 16:09:51 -08:00
Linus Torvalds
a1472a7247 Merge branch 'Subsurface-branch' of github.com:Subsurface-divelog/libdc into Subsurface-branch
Merge with Dirk's cleanups.

I had intentionally not updated my tree while I was pondering the
upstream merge with Jef's iostream changes, so I didn't have Dirk's
cleanups in my tree when I did that big merge.

This merge was trivial in comparison.

* 'Subsurface-branch' of github.com:Subsurface-divelog/libdc:
  Correctly determine git SHA if libdivecomputer is a git submodule
  Disable a couple of overly aggressive warnings
  Add configure flag to explicitly enable BLE support
2017-12-12 14:02:53 -08:00
Linus Torvalds
8a34d822ff Merge remote-tracking branch 'jef/master' into Subsurface-branch
Rough merge of upstream libdivecomputer.

This is mainly about making the new iostream code upstream, although we
don't actually use it.

It abstracts out the the old serial and usbhid code, but we end up still
using our own 'custom_io' interface because the iostream code doesn't do
it right.

* jef/master:
  Correctly determine git SHA if libdivecomputer is a git submodule
  Don't accept a NULL pointer as parameter
  Add support for semi-closed circuit diving
  Detect dives with invalid profile data
  Implement the serial communication functions as no-ops
  Move the socket code to a common file
  Add support for a custom I/O implementation
  Port the USB HID code to the new I/O interface
  Port the bluetooth code to the new I/O interface
  Port the IrDA code to the new I/O interface
  Port the serial code to the new I/O interface
  Add a new abstract I/O interface
  Post release version bump to 0.7.0
2017-12-12 13:59:29 -08:00
Dirk Hohndel
db70c581a6 Correctly determine git SHA if libdivecomputer is a git submodule
In the case of a submodule, the .git file is a text file pointing to the
correct module in the parent's .git folder. The git rev-parse works
correctly in both cases.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-06 21:23:22 -06:00
Dirk Hohndel
f5aee8198f Disable a couple of overly aggressive warnings
-Wextra and -Wpedantic are creating more noise than useful warnings.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-04 13:53:40 -08:00
Dirk Hohndel
506bcec3cd Add configure flag to explicitly enable BLE support
This way BLE dive computers that are otherwise conditional on USBHID will be
built on platforms that support them but don't have USBHID (like iOS).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-12-04 13:42:25 -08:00
Linus Torvalds
77f87bebe3 EON Steel: remove a few unused variables
Most of the new warnings due to compiler flags are just unnecessary
noise, but let's clean up at least the obvious and unquestionably valid
ones.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-12-04 10:43:20 -08:00
Linus Torvalds
54f6bff929 Merge tag 'v0.6.0' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Sync up with upstream cersion 0.6.0.

Annoying merge, mainly because a lof of the changes Jef had done are
actually changes that came from our Subsurface branch, but in a
different form, because Jef doesn't actually take patches directly from
us.

Why? I don't know.

* tag 'v0.6.0' of git://git.libdivecomputer.org/libdivecomputer:
  Release version 0.6.0
  Fix some potential buffer overflows
  Fix some casts with constant pointers
  Enable some useful compiler warnings by default
  Generate html documentation from the manpages
  Fix the decoding of the ndl/deco information
  Decode the firmware version for the iDive series
  Add support for the Suunto Eon Core
  Locate the most recent dive
  Add EON Steel time sync capability
  Improve the progress events
  Detect the model number using the hardware type
  Shearwater: add support for remaining gas time
  Shearwater: extract tank sensor data for log version 7
  Shearwater: extract log version from header
2017-12-04 10:18:23 -08:00
Jan Mulder
8c443c5abc build: ignore the build from git
Now as a submodule, the change in libdivecomputer created by the
build process is annoying. Just ignore it.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-12-04 02:12:13 +01:00
Linus Torvalds
238a3734a5 Add support for new Suunto EON Core dive computer
Nick Shore reports that it seems to act exactly like an EON Steel, just
with a different USB device ID.

Acting like the EON Steel is not a surprise: it does seem to be the same
dive computer, just in a smaller and lighter package (same screen size,
but more compact body and without the stainless steel to make it less
than half the weight).  Looks like the battery is smaller, but the
electronics are likely the same.

We probably really should have some way to add new device ID's without
having to add whole new model numbers etc.  It's not the first time this
happens (see the Scubapro Aladin Square vs the G2), and it's likely not
the last time.

Reported-by: Nick Shore <support@mac-dive.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-19 15:36:39 -10:00
Linus Torvalds
c44d2a8faf Merge remote-tracking branch 'jef/master' into Subsurface-branch
Sync with the upstream version of the Aladin Square.

This picks the same model name that Jef picked in uwatec_smart_parser.c.

* jef/master:
  Add support for the Scubapro Aladin Square
2017-11-16 15:37:28 -08:00
Linus Torvalds
a2f358f0b5 Add support for Scubapro Aladin Square
It works like the G2, but has a different model number, and different USB device ID.

Lots-of-testing-by: Vincent <vavincavent@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-16 15:24:28 -08:00
Linus Torvalds
9d7335dc6d Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with Jef's upstream libdivecomputer:

 - some OSTC parsing fixes, including getting the initial CNS into the
   first sample

 - syntactic cleanups to the Scubapro Aladin Sport Matrix support to
   match upstream

* git://git.libdivecomputer.org/libdivecomputer:
  OSTC: initialize initial CNS from header
  Use an out-of-range value as undefined
  Support for the Scubapro Aladin Sport Matrix.
2017-11-15 08:51:54 -08:00
Linus Torvalds
4dce920c79 Scubapro G2 usb: always use exactly 32-byte packets (plus report byte)
It turns out that the Scubapro G2 itself does not care at all, but
apparently some of the other dive computers that use the same protocol
do).

In particular, Vincent reports that his Scubapro Aladin Square downloads
ok with the USB ID's switched to c251:2006, but only if we send 32-byte
USB HID payload packets, even though the command itself is much smaller.
Otherwise it will simply not reply at all.

To actually download correctly, we'll still need to do some model-
specific USB ID updates, and there will be some model changes for the
Aladin Square, but this at least fixes the transport side.

Jef had actually already done this because of the Windows behavior side,
I just hadn't thought it could possibly matter. Mea Culpa.

Reported-and-tested-by: Vincent <vavincavent@gmail.com>
Cc: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Cc: Jef Driesen <jef@libdivecomputer.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-15 08:42:35 -08:00
Linus Torvalds
7de3a549ee EON Steel: explicitly sort the dive directory listing
The code relied on the dives being ordered by date in the directory
listing, which is normally true.  But once the dive computer fills up
(after 400 dives or so), it starts re-using entries in the dive list,
and the dive directory is no longer ordered by date.

This matters because we want to download the latest dives first, since
subsurface will generally stop downloading once it finds an existing
dive.

NOTE! If you screw up the date on the dive computer, the old behavior
was possibly more to your liking, since - as long as the dive list
hadn't filled up - it wouldn't really order by date, but by dive
creation.

However, I don't see any way to get that information once the dive list
has filled up, so "order by dive date" is as good as it gets.

If you do screw up dates, and you want to download new dives that are
"older" than the dives you already have, you will need to basically set
the "download all dives" flag, and then select the new dives manually.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-03 10:58:10 -07:00
Berthold Stoeger
06c34fc8b0 Fix model number of the Scubapro Aladin Sport Matrix.
The model number was wrong. Mea culpa.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-11-01 08:28:08 -07:00
Linus Torvalds
e177b28627 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Pull Uwatec date handling fix from Jef Driesen.

This merges with upstream libdivecomputer, where Jef fixed the overly
complicated and fragile date parsing of the Uwatec smart backend.

It used to try to guess the base epoch of the dive computer by comparing
current time on the dive computer with the current time on the
downloader, but if the time and date of either was wrong (and the date
on dive computers often is) that would get the wrong answer.

* git://git.libdivecomputer.org/libdivecomputer:
  Replace the clock calibration with a fixed epoch
2017-10-29 07:16:25 -07:00
Berthold Stoeger
8a84ece7d0 Support for the Scubapro Aladin Sport Matrix.
The protocol is identical to the G2 protocol, with the exception of a
missing handshake.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-10-29 07:15:14 -07:00
Linus Torvalds
0099aeeb70 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer: USB HID fixes.

* git://git.libdivecomputer.org/libdivecomputer:
  Make the initialization thread-safe
  Initialize the usb library only once
2017-10-19 15:57:16 -04:00
Linus Torvalds
07f5777c71 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer:

 - workarounds for Windows libusb and hidapi issues

 - misc random cleanups/noise

 - rename DiveSystem to Ratio

 - make Cochran with better with FTDI

 - new support for: Suunto D4f, Ratio idive tank pressure, and Sherwood
   Insight temperature and Oceanic ndl/deco sample.

* git://git.libdivecomputer.org/libdivecomputer:
  Workaround for a Windows libusb issue
  Use a fixed size packet for sending
  Replace the size macro with the sizeof operator
  Use the correct printf format for the size_t type
  Move platform specific macros to a common header file
  Use the correct data type for the return value
  Rename the DiveSystem vendor to Ratio
  Fix the Sherwood Insight temperature
  Implement the ndl/deco sample
  Change communication parameter to work better with FTDI
  Retry read operations on failure
  Add support for the Suunto D4f
  Implement the tank pressure
2017-10-05 15:02:56 -07:00
Linus Torvalds
c0f025b019 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer:

 - uwatec cleanups and fixes (G2/trimix parsing etc)

 - event and bookmark fixes for Oceanic, iDive/iX3M and Aqualung i300

* git://git.libdivecomputer.org/libdivecomputer:
  Use more descriptive names
  Use two passes to parse the profile data
  Fix the Uwatec trimix data format
  Implement the ndl/deco, rbt and bookmark samples
  Implement the setpoint sample for the iDive and iX3M
  Implement the ndl/deco sample for the Aqualung i300
  Update the msvc project file
2017-09-06 10:58:21 -07:00
John Van Ostrand
3602a324b8 Flagged Cochran DCs for FTDI communications
This with serial_ftdi.c changes and other libdivecomputer changes
enables Cochran DCs to work with libftdi on android devices.

Signed-off-by: John Van Ostrand <john@vanostrand.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-09-06 10:57:56 -07:00
Dirk Hohndel
aa0b522ab8 Mark 3 more Shearwater dive computers as BLE
Technically this is inaccurate because while some Perdix and Petrel 2
models do in fact support dual stack, the Petrel only does BT. But
the Petrel 2 identifies itself as Petrel via BT, so we need to flag
them both here.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-20 21:01:31 -07:00
Linus Torvalds
d7503b05e2 Scubapro G2: add zero report type to USBHID packet write
Jef reports that this is required for HIDAPI, and while I would really
like to just make the report type part of the custom packet_io interface
instead of making it visible here, this is the minimal fix for now.

See commit d251b373becc ("Add a zero report ID to the commands"), which
does the same thing, except for the fact that we now need to treat BLE
and USB HID differently.

I may still end up teaching the USB HID custom-IO layer to add the
report ID byte, and just specify it at dc_usbhid_custom_io() time
instead.  That would make the G2 code not have to care about the
transfer protocol again.

(But the other user of USB HID - the Suunto EON Steel - has much bigger
protocol differences between USB HID and BLE, so the whole "try to be
protocol-agnostic" hope may be just a pipe dream anyway, and it's just
the Scubapro G2 that _could_ work that way).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-20 19:16:21 -07:00
Linus Torvalds
aed80fe7fd Add EON Steel time sync capability
The EON Steel can use the new 'timesync' interface to set the time
automatically from the computer it is connected to.

This also regularizes the EON Steel command names a bit, and adds a few
new commands (you can also read the time etc, which this doesn't
actually use).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-08-19 14:35:05 -07:00
Linus Torvalds
928be1f45b Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer from Jef:

 - more Cochran work from John Van Ostrand

 - new 'timesync' interface to synchronize the clock on a dive computer

 - support for Aqualung i200

 - misc updates (Cressi Leonardo fix, OSTC 3+ renaming, fix surface pressure on iX3M, idive salinity parsing)

 - HIDAPI work.

It turns out that HIDAPI is not compatible with libusb in the actual
packet sending path, so this will need some more cleanups - Jef doesn't
see the issue because he doesn't have a generic packet IO layer and
doesn't share packets with the BLE code.

* git://git.libdivecomputer.org/libdivecomputer: (25 commits)
  Add basic timezone support
  Add time synchronization to the example application
  Implement the new api for the HW devices
  Add support for synchronizing the device clock
  Use hidapi as the default USB HID library
  Workaround for a Windows hidapi issue
  Reset the number of bytes to zero on error
  Add a zero report ID to the commands
  Fix compatibility issue with hidapi
  Implement the salinity field
  Fix the atmospheric pressure for the iX3M
  Rename the OSTC 3+ to OSTC Plus
  Locate the most recent dive using the logbook pointers
  Add support for the Aqualung i200
  Add event handling to TM model
  Fix profile buffer size and address size
  Add three event codes
  Add support for the Commander TM
  Dump function no longer assumes reads begin at byte 0
  Remove unneeded function
  ...
2017-08-19 13:51:56 -07:00
Linus Torvalds
9fd6635cf6 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with upstream libdivecomputer from Jef:

 - Jef merged my Scubapro G2 work, but renamed everything, and didn't
   get the newer IO model code. Very annoying.

   I went along with changing the G2 model family name to
   DC_FAMILY_UWATEC_G2 just to keep some of the basic infrastructure
   more easily mergeable.  But his uwatec_g2 version is not usable.

 - Cochran updates from John Van Ostrand

 - Misc improvements from Jef:
    * divesystems idive improvements
    * Oceanic OCS freedive mode
    * ppO2 callback cleanup

 - Some transport type work:
    * changes to IRDA configuration
    * basic bluetooth rfcomm transport mode

* 'master' of git://git.libdivecomputer.org/libdivecomputer: (35 commits)
  Removed unused code
  Fixed duplicate gasmix event reports
  Added decompression event handling for the Commander
  Fix bad profiles when profile ringbuffer wraps around
  Changed cochran_comander_profile_size function parameters
  Fixed location and encoding of Commander II pointers
  Use a local variable for the layout pointer
  Add new EMC device model string
  Add support for Pre-21000 s/n Commander dive computers
  Fix problems with wrapped logbook ringbuffer
  Retry read operations on failure
  Change profile download to be incremental
  Fix the id string offset
  Fix the progress events
  Use the trimix data format
  Use the correct model number
  Enable more fine grained progress events
  Abort with an error if the buffer is too small
  Use the standard libdivecomputer error codes
  Scubapro G2: add missed command packet logging
  ...
2017-07-10 14:00:47 -07:00
Linus Torvalds
eed75cb0be Clean up Shearwater string handling
And remove the nasty and disgusting transmitter data handling code that
Dirk added to work around his misunderstanding of the parsing code.

This code now collects the various states of the transmitter batteries
throughout a dive and reports the most meaningful summary in the end. It
also rewrites the rest of the string handling code to be architecturally
cleaner.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-09 14:36:05 -07:00
Dirk Hohndel
4a3f7a7cce Mark DC descriptors with supported transport
The syntax is trivial.
"// FTDI" for FTDI cable support
"// BT"   for classic Bluetooth support
"// BLE"  for Bluetooth LE support

We can then parse this information during the Subsurface build process
and create the (hopefully correct) support matrix for dive computer
download from the mobile apps.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-08 15:25:22 -07:00
Dirk Hohndel
8ea8cebb4e Shearwater: correctly handle the different models
That weird 'petrel' argument and member variable can easily be replaced
by looking at the model.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 18:00:54 -07:00
Dirk Hohndel
6f4776d6c4 Shearwater: detect the hardware type
Stop pretending that all the devices since the Petrel are the same. They
actually aren't. So let's detect them and correctly identify them.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 17:29:41 -07:00
Dirk Hohndel
04073759a8 Shearwater: add transmitter battery information
This should be a STRING callback, but those come from the header and we
don't have the information until after we have parsed all the samples.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
84ad5aa5ad Shearwater: report battery type for logversion >= 7
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
41417fbe59 Shearwater: add support for remaining gas time
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 16:36:50 -07:00
Dirk Hohndel
8736a6dca1 Shearwater: extract tank sensor data for log version 7
The first dive computer to support this is the Perdix AI. Interestingly,
this keeps track of two sensors at all times. I haven't seen data with
two sensors active, yet.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 09:54:50 -07:00
Dirk Hohndel
d85481cefd Shearwater: extrac log version from header
The earliest document I have references log version 6. There are
apparently older versions, but I don't know what the differences
are. Before version 7, the log version wasn't always reliably
stored, so we assume 6 is the minimum and use 7 (or later) if we
find it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-07 07:04:13 -07:00
Linus Torvalds
0143be5497 Fix incorrect placement of -lz (zlib) in autotools build
When I added support for the new Suunto EON Steel bluetooth download, I
needed crc32(), and instead of cooking my own (libdivecomputer does do
its own versions of the simpler crc functions), I made libdivecomputer
just depend on zlib instead, which provides a convenient crc32() function.

But I didn't add the new linker flag (-lz) in the right place in the
automake.  It worked fine for me on Linux, but apparently not so well on
macos.

This fixes it.

Reported-and-tested-by: Benjamin <nystire@gmail.com>
Tested-by: Axel Richter <Axel.Richter@freenet.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-28 13:04:24 -07:00
Linus Torvalds
208807180a Update the operations in 'custom_io' to consistent calling conventions
The serial ops used a legacy calling convention that passed in just the
pointer to the userdata pointer (ie the first argument to the functions
was "void **userdata").

That's actually very inconvenient, because the custom IO data can not
only contain other interesting information that was filled in by the
custom IO provider, it also made it harder to chain these things
together, as exemplified by the core to emulate serial over the packet
interface in the subsurface bluetooth code.

This also adds the 'dc_context_t' field that is passed to the packet
routine open.  That can allow the open routine to override the
'custom_io' details of the context at open time (to allow nested
custom_io operation).

Note that callers of the open function need to be aware that the
'custom_io' can be changed by the act of opening a custom_io, and the
value shouldn't be cached in some local variable.

Finally, this adds a new user-supplied opaque pointer

	dc_user_device_t *user_device;

to the custom_io descriptor.

The 'user_device' data is filled in when registering the custom_io with
data that the custom IO open() routines can use.  This is different from
the existing 'userdata' in that the 'user_device' is filled in before
dc_open_device() is called (and "open" can then use it to limit what
kinds of devices it looks for, for example).

In contrast, the existing 'userdata' field is filled in by the
"xyz_open()" routines, and contains the data necessary for the IO
itself.

The SSRF_CUSTOM_IO define is updated to v2 to indicate the new
interfaces.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-27 13:38:45 -07:00
Linus Torvalds
3aa40c6135 Merge branch 'BLE-downloaders' into Subsurface-branch
This merges the Suunto EON Steel and Scubapro G2 BLE downloading updates
into the main Subsurface branch.

The basic infrastructure had been done earlier, this is just the tweaks
to actually take advantage of the BLE GATT back-end in Subsurface for
those two dive computers.

The actual subsurface code that exposes BLE GATT interfaces has not been
made public yet, it's too ugly, and will probably make small children go
blind.  But I'll try to clean it up a bit and get it out for wider
testing asap.

* BLE-downloaders:
  Scubapro G2: update for BLE downloading
  Complete the EON Steel HDLC encoding/decoding work
  Teach the EON Steel about HDLC encoding of the command packets
2017-06-24 15:14:08 -07:00
Linus Torvalds
accc63df11 Scubapro G2: update for BLE downloading
The code actually almost worked as-is, but for a tiny detail: the USBHID
packet reception code always receives a full 64-byte packet, while BLE
GATT will return how much it actually received.

The other difference is that USB HID is so fast that it didn't make any
difference where the progress was updated, it took about a second to
download everything.

BLE GATT is not fast to begin with, and the G2 may be particularly slow.

So with the BLE backend, you really do want progress updates for each
packet received, because the dump is going to take a while...

But with the trivial packet verification change, and with the progress
report updates, everything "JustWorks(tm)" over BLE.

Of course, I haven't committed the actual Subsurface BLE transfer parts
yet, because they are some incredibly ugly stuff with fragile bits and
pieces.  But the fact that I can now download from two different dive
computers does mean that I think it's getting to the point where I will
just submit even my ugly code to Dirk.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-24 15:01:56 -07:00
Linus Torvalds
ca115b97e2 Complete the EON Steel HDLC encoding/decoding work
The previous patch did the HDLC encoding on packet send, this does the
HDLC decoding on the receive side.

In order to properly check the data integrity, the HDLC-encoded packet
needs to be fully received before it can be processed.  So while the HID
downloading continues to work packet-by-packet, the HDLC encoded BLE
GATT stream needs a temporary buffer for the data that gets filled as we
ask for the reply header.

Right now only the old USB HID path is actually tested, because I
haven't flushed out the packet receiving side in subsurface yet.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-23 16:41:22 -07:00
Linus Torvalds
c863db02f0 Teach the EON Steel about HDLC encoding of the command packets
The BLE GATT transport ends up using HDLC for the stream encoding,
unlike the USB HID side.  The EON Steel BLE GATT protocol actually does
that for both the commands and for the replies, but this converts only
the command side, because that's the simpler one.

The reply side code will need to be re-architected a bit, because right
now it is very much oriented towards beign able to do everything one
single packet at a time (which is true for USB HID) rather than treating
the packets as a stream of data (as is necessary for the CRC32
verification and to handle the escaping of the 0x7e/0x7d bytes in the
stream).

So with this change, you can't actually do a download over BLE, but I
was able to verify that the first command transfers correctly, and the
EON Steel replies to it over Bluetooth LE GATT.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-22 21:44:28 -07:00
Dirk Hohndel
70526a47eb Bump our private version
Given that this is a fairly significant change, this seems
justified.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-06-22 18:48:14 -07:00
Linus Torvalds
b7699b6985 Convert Suunto EON Steel and Scubapro G2 to dc_usbhid_custom_io helper
This means that they still default to their respective USB devices, but
you can now set custom IO structure to pass in your own data.

Not only will we hopefully have some kind of BLE support, you could also
use this to simply emulate packets from a log-file by having a packet
replay (or by actually emulating a device).  Of course, you can already
do this by actually emulating the device in a virtual environment, but
it might be useful for some kind of libdivecomputer testing environment.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-18 16:28:59 +09:00
Linus Torvalds
e590739260 usbhid: add helper function to create a usbhid 'custom_io_t'
Basically, this alows us to hide the usbhid code behind the custom_io
abstraction, so that a dive computer could either be given a supplied
custom_io structure, of if none is given, would create one for a USBHID
device.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-18 16:28:35 +09:00
Linus Torvalds
60efc308d2 Rename 'custom_serial' as 'custom_io' across the board
The custom IO handlers will be extended to not just do serial line
emulation (generally over Bluetooth rfcomm), but do BLE too.

BLE does not look like a serial protocol at all, it's packet-based, and
we may have to add specific routines to indicate which GATT endpoints to
use etc.  But like the traditional custom serial code, we want to do the
actual IO not from within libdivecomputer, but from the user of the
library (because the BLE support will require things like the Qt
Connectivity layer - and we do not want libdivecomputer to have to link
against something like Qt).

So this renames 'custom_serial' to 'custom_io', and instead names the
individual member function pointers 'serial_*' to make it clear that
those members are for serial communication.

It also adds new placeholders for packet_open/close/read/write.  Note
that while these may look similar to the serial counter-parts, they are
not the same or even necessarily mutually exclusive.  It is possible the
the caller fills in one or the other (or both), and they would be used
independently.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-18 16:28:24 +09:00
Linus Torvalds
e9754bac64 Scubapro G2: make the backend_table_t contain the right values for the G2
Not that anybody should ever use that old-style family/model thing
anyway, so I considered just removing the g2 entry instead.  But dctool
still uses this deprecated interfsce to pick a dive computer.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15 18:22:50 +09:00
Linus Torvalds
323a606688 Scubapro G2: add missed command packet logging
I did the packet logging for the received data side, but forgot to do
the same thing on the command transfer side, which makes the debug logs
a bit less useful.

Of course, it turns out that a bug in subsurface means that the logging
never gets enabled anyway even when you ask for it, so right now this
particular misfeature didn't matter.  I'm hoping Tomaz/Dirk can fix the
UI widget problem.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15 07:01:51 +09:00
Linus Torvalds
bae506397e Scubapro G2: add back the initial handshake code
When doing the G2 downloader, I dropped the initial handshake as I tried
to keep the code minimal, and the handshake didn't seem to make any
difference what-so-ever to me.

And it probably doesn't matter for anybody else either.  But the code
isn't working for some people, and maybe it does actually matter.

More importantly, Scubapro's own LogTRAK application does send those two
initial commands, and it's probably a good idea to minimize the
differences between the different downloaders anyway, so add the
handshake sequence back in.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15 06:36:57 +09:00
Linus Torvalds
7f21c27b7a Scubapro G2: clean up unused field
Jef Driesen correctly points out that the 'address' field is just
leftover from the IrDA code, and is meaningless for the USB HID
transport version of the Scubapro G2.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-15 06:27:21 +09:00
Linus Torvalds
df9984e123 Add initial Scubapro G2 frontend
The back-end parser seems to be the same as for the Uwatec Smart (aka
Galileo Sol).  At least that's the assumption right now.

The downloader just uses USB HID (very similar to EON Steel) rather than
the horrible IrDA thing.

There's also eventually a BLE thing, but that's for the future.

This is an unholy mixture of the Uwatec Smart downloader logic and the
EON Steel usbhid transfer code.  The back-end is pure Uwatec Smart
(model 0x11, same as Galileo Sol).

I'm not at all sure this gets everything right, but it downloads
*something*.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-06-08 22:16:14 -07:00
Linus Torvalds
a0c5b5b53b Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream libdivecomputer changes as requested by Jan Mulder.
 "DiveSystem iX3M:
   - Add support for new iX3M models
   - Add support for new iX3M APOS4 firmware
   - Add iX3M firmware version to the devinfo event (ix3m)

  Shearwater:
   - Report the ppO2 in external O2 sensor mode only (Shearwater)
   - Replace the constant offset with a scaling factor (Shearwater)
   - Apply the calibration correction only for the Predator
   - Report individual sensor values
   - Predator: don't report PPO2 unless in CC mode

  Misc:
   - Fix Sherwood Wisdom 3 memory layout
   - Implement read and write functions for OSTC3
   - Add support for Mares Quad
   - Fix uwatec handshaking error handling"

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  Add support for the new models
  Add support for the new iX3M APOS4 firmware
  Add the firmware version to the devinfo event
  Report the ppO2 in external O2 sensor mode only
  Replace the constant offset with a scaling factor
  Apply the calibration correction only for the Predator
  shearwater: Report individual sensor values
  Predator: don't report PPO2 unless in CC mode
  Fix the Sherwood Wisdom 3 memory layout
  Implement the read and write functions for the OSTC3
  Don't ignore handshaking errors
  Add support for the Mares Quad
2017-05-25 10:26:49 -07:00
Jan Mulder
9df029a704 OSTC3: add battery percentage
From firmware version 2.15, the battery percentage is shown on the
unit (in the logbook that is, it was shown on the display for a very
long time). The used byte in the OSTC3 seems to be populated since
firmware version 2.10. The new percentage data is added to the
"battery at end" voltage data, and a V is added to denote the unit
of the voltage.

In addition, reordered the DC_FIELD_STRINGs a little, so that the
serial is on top.

Further, changed BUFLEN to 32 (as in 84eb59c) due the the length
of the new battery notation.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-30 22:10:35 +02:00
Linus Torvalds
29135bcdf8 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream libdivecomputer changes from Jef Driesen.

The most noticeable part is Jen Mulder's OSTC3 initial setpoint
addition, which fixes the OSTC3 data in CCR3 mode.

But also various cleanups and fixups from Jef.

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  OSTC3: set initial setpoint in profile data
  Remove unused parameters
  Cleanup the extract dives functions
  Remove unnecessary helper functions
  Remove deprecated functions from the public api
  Remove unnecessary include statements
  Fix the firmware version and serial number
  Add support for the Uwatec Aladin Tec 3G
2017-04-29 16:37:40 -07:00
Linus Torvalds
b04f393b97 Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream libdivecomputer changes from Jef Driesen.

No major changes and no conflicts except for a trivial one where Jef had
marked a couple of private functions 'static' and our versions had
extended the argument lists of those functions.

This just updates to the current upstream state of libdivecomputer,
where the bulk of the changes come mainly from the new ringbuffer helper
code, but there are various other small misc fixes and cleanups.

* git://git.libdivecomputer.org/libdivecomputer:
  Disable the deco events
  Replace the deco events with a deco sample
  Report errors from the close function
  Mark the private function as static
  Fix a bug in the tank pressure samples
  Disable freedive mode for the Uwatec Aladin Tec 2G
  Mark the private function as static
  Fix some compiler warnings
  Fix some more null pointer dereferences
  Use a more efficient download algorithm
  Use the new ringbuffer stream
  Add a common ringbuffer reading algorithm
  Improve the robustness of the IrDA I/O code
  Fix a few null pointer dereferences
  Fix the number of gas mixes
  Always use the sample timestamp as the base value
2017-04-12 08:24:04 -07:00
Jan Mulder
84eb59c3ce Prevent buffer overrun
When compiled with older Microsoft libraries, the unsafe implemention of
snprintf results in non-null terminated strings, causing numerous subsequent
issues. This fix just enlarges the used buffer to accommdate longer strings.
A more complete solution would include the use more recent Microsoft libraries in
the build process. The larger buffer is still need then, to prevent trucated
(but proper null terminated) strings.

ref: https://github.com/Subsurface-divelog/subsurface/issues/301

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-12 12:45:17 +02:00
Dirk Hohndel
ca04147126 Merge pull request #2 from torvalds/upstream-from-jef
Pull upstream updates from jef
2017-02-01 21:49:21 -08:00
Linus Torvalds
71cf0a5c69 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into sync-with-upstream
Merge upstream libdivecomputer changes from Jef Driesen.

The most notable one is how libdivecomputer no longer sends the
GASCHANGE events, but uses DC_SAMPLE_GASMIX instead.

We still turn it into a SAMPLE_EVENT_GASCHANGE2 event internally in
subsurface, since we want all the normal event handling to trigger.

* 'master' of git://git.libdivecomputer.org/libdivecomputer: (21 commits)
  Document the date/time functions
  Document the public api with man pages
  Add support for the Cressi Drake
  Detect overwritten dive profiles
  Ignore tank pressure if no sensor is attached
  Add support for the tank field
  Add support for the salinity field
  Use the sample interval from the settings
  Update the Aqualung i750TC parser
  Toggle the DTR line during setup
  Implement the read function
  Add doxygen documentation to the build system
  Add support for the Aqualung i750TC
  Fix the Windows version resource build
  Force the dive mode to gauge
  Add support for the dive mode
  Report the initial gas mix on the first sample
  Remove the deprecated gas change events
  Add support for the Hollis DG02.
  Add support for the Oceanic F10.
  ...
2017-01-16 16:01:10 -08:00
Anton Lundin
3f74840f4c Fix bug in ostc deco info string parsing
The code was just if instead of else if by accident.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 14:16:17 -08:00
Anton Lundin
2e650b68ae Teach ostc deco model info strings about OSTC4 VPM
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 13:49:06 -08:00
Anton Lundin
6fccf5923f Correct shearwater Deco model info string
The literal % where in the wrong place.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 13:49:06 -08:00
Anton Lundin
a6421b2f7b Correct firmware string for OSTC4
OSTC4 stores firmware in another format than OSTC3's.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 11:54:49 -08:00
Anton Lundin
19b560d9b2 Fix logging of Custom Write
This way we actually trace print the written buffer, even if the caller
doesn't care about how much data he/she actually wrote.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2017-01-08 11:54:49 -08:00
Linus Torvalds
534dd2f34b Merge tag 'v0.5.0' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge upstream version 0.5.0.

Some small updates from Jef Driesen since the last sync, but let's sync
with the real 0.5.0 release.

* tag 'v0.5.0' of git://git.libdivecomputer.org/libdivecomputer:
  Release version 0.5.0.
  Include the public header in the implementation file.
  Add explicit casts for the msvc C++ compiler.
  Add some workarounds for the msvc compiler.
  Update the msvc project file.
  Add missing header files to the Makefiles.
  Add support for the Subgear XP-Air
2016-09-30 14:10:59 -07:00
Linus Torvalds
4ec7283841 Merge branch 'master' of git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
Merge with Jef Driesen's upstream.

Jef has updated his branch with about half of the EON Steel fixes, but
still refuses to admit that the string model is much superior to his
crazy "random numbers that can't actually describe anything properly"
model, and left out all those parts.

But Jef also made a generic HID layer thing that cleans things up (but
causes a spurious warning about a failed usb hid read due to the "clean
out old data" code that *expects& the failure), and fixed his version of
the HW Frog firmware, so this cleans up that issue.

We also now have that gas mix parsing fix for the Aladin Tec 2G properly
merged, so that our cherry-pick won't cause merge issues later.

* 'master' of git://git.libdivecomputer.org/libdivecomputer:
  Fix the firmware version for the HW Frog.
  Use the new USB HID backend for the Eon Steel.
  Add a dummy backend for systems without USB HID support.
  Use the hidapi library on Mac OS X.
  Add a new USB HID communication backend.
  Add a configure option to build without libusb.
  Restore the sample events.
  Suunto EON Steel: initialize the tank 'gasmix' index
  Suunto EON Steel: do the proper enum lookup for a few more cases
  Suunto EON Steel: fix the event begin/end flag
  Suunto EON Steel: split out gas info parsing
  EON Steel: look up enum descriptor strings
  EON Steel: pass in the type descriptor to samples that need it
  EON Steel: mark tank cache initialized when filling it in
  EON Steel: fix uninitialized field cache entries
  Initial Suunto EON Steel CCR support
  Suunto EON Steel: add descriptor debugging output
  Add tank size reporting for Suunto EON Steel
  Fix the gas mix parsing for the Aladin Tec 2G.
2016-09-19 10:41:42 -07:00
Dirk Hohndel
11fec04865 fix compile error
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 08:27:24 -07:00
Gaetan Bisson
af84bd10fd export new symbol, needed by subsurface
Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:31:37 -07:00
Jef Driesen
a568c756a1 Fix the gas mix parsing for the Aladin Tec 2G.
Unlike the other models, the Aladin Tec 2G uses only a single byte to
store the oxygen percentage, and there is no need to manually re-map the
deco mix.

Normally, the oxygen percentage is stored using two bytes (little endian
byte order). Thus for a device supporting two gas mixes, four bytes will
be used, and the corresponding gas mix id for each byte is as follows:

  ID: 0 0 1 1

After re-mapping the id of the deco mix, this becomes:

  ID: 0 0 2 2

Since oxygen percentages are limited to the range 0-100%, the highest
byte (marked with an X) should always be zero and can thus be ignored:

  ID: 0 X 2 X

Now, because an oxygen percentage of zero indicates a disabled gas mix,
this is equivalent to a device supporting three (or even four) gas
mixes, each stored using only a single byte:

  ID: 0 1 2 3

We can take advantage of this knowledge to avoid having to re-map the
deco mix id.
2016-09-18 07:15:30 -07:00
Anton Lundin
3ea2795bf1 Fix merge error of AQUAI300 memory layout
This removes the additional entry for AQUAI300, as it was done in "Fix
the memory layout for the Aqualung i300." (1e22760f9102ac).

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:14:23 -07:00
Anton Lundin
89111ebb2a Build example applications by default again
A while back, the example applications where broken in our
Subsurface-branch, and got disabled by default. This re-enables them to
sync better with upstream.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:14:14 -07:00
Anton Lundin
a6538ae7da Set error status if transfer fails in close
This fixes whats probably was a merge error. This is a resync with
upstream.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:13:55 -07:00
Anton Lundin
f7d2086675 Don't overwrite status
This removes whats probably a merge error, that overwrites the return
status.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:13:44 -07:00
Anton Lundin
4c5b51f851 Add blank row to match upstream
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:13:27 -07:00
Anton Lundin
20d268acdb Remove last traces of our old custom serial code
This is just to make future merges easier.

There were nothing left of Claudiu's code in those files, so thats why i
removed the copyright lines.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-09-18 07:13:13 -07:00
Anton Lundin
94e7a77d01 Re-implement custom serial in a new way
This re-implements the custom serial concept in a new way. This way
doesn't touch any of the backend code, it just introduces a optional
redirection layer in the existing serial backends.

This implementation supports more serial operations to, so we can
support more backends this way.

Hooking into the existing serial backends might look ugly but its
probably the best way to make sure this patch conflicts as little as
possible with upstream.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-09-17 14:09:37 -07:00
Anton Lundin
7e086f697d Remove the old custom serial code
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2016-09-17 14:09:37 -07:00
Linus Torvalds
f9db4ca97c Merge git://git.libdivecomputer.org/libdivecomputer into Subsurface-branch
This is a rough merge of the upstream libdivecomputer changes.

I say "rough", because this disables the custom serial code as it
clashes very badly with Jef's new dc_serial_t abstraction.

Anton Lundin has patches on top of this to re-introduce the custom code
in a way that integrates better with the upstream libdivecomputer state.

* git://git.libdivecomputer.org/libdivecomputer: (42 commits)
  Add support for the Sherwood Vision.
  Fix the decoding of the maximum depth.
  Improve the default layout detection.
  Add a warning for unsupported devices.
  Fix the temperature for the Tusa Zen Air.
  Add support for the Aqualung i550T.
  Use the new settings field for the salinity.
  Fix the parsing of freedives.
  Detect the gauge and freedive mode correctly.
  Add the salinity field for the Aladin Tec.
  Add support for the Scubapro Mantis 2.
  Fix the decoding of the dive time.
  Add support for the Scubapro Mantis.
  Fix the Aeris 500AI serial number.
  Add the serial number encoding to the layout.
  Add salinity and timezone fields to Aladin Tec 2G
  Add NDL and RBT for the ATOM31 and I450T
  Add support for the new extended hardware descriptor.
  Update the OSTC device descriptors.
  Add a workaround for an OSTC4 firmware bug.
  ...
2016-09-17 14:08:32 -07:00
Linus Torvalds
ed8b8f1221 Suunto EON Steel: extend our string space
We only used to save 16 extended strings per dive from the EON Steel
download, which is _plenty_: it's not like we actually generate that
many strings.  Firmware version, battery status, transmitter info -
there's just not that many strings.

Oops.

Except if you have lots of transmitters.  Then each wireless transmitter
will have three strings each, for transmitter ID and beginning/ending
battery status.

I only have one, but Andreas Klein has four.  And it took me
embarrassingly long to realize that he really did have them on the
dives, because after the first two transmitter IDs got recorded, the
string space filled up and we silently dropped the rest.

But I have learnt my lesson.  Future generations will talk about how I
said "32 strings will be enough for anybody".

But at least it should be enough for a few more transmitters.  Somebody
should extend this some better way, but I'm still chasing other issues.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:45:33 -07:00
Linus Torvalds
6fa9f1566f Suunto EON Steel: initialize the tank 'gasmix' index
The gasmix query interface considers cylinders and gas mixes independent
things, so the tank data structure has a pointer to the gasmix index.

But the EON Steel treats cylinders as just having a gasmix (and so does
subsurface, for that matter), so the gasmix index for the tank is just
the same as the tank index.

But we never filled it in, so you'd always see a "gas index" of zero,
and subsurface would end up warning each time about how the gasmix index
doesn't match the cylinder index (but because subsurface actually agreed
with EON Steel, it worked despite the warning).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:45:19 -07:00
Linus Torvalds
d11d30999b Suunto EON Steel: do the proper enum lookup for a few more cases
Instead of hardcoding the enum values for setpoint type and gas type,
use "lookup_enum()" to actually parse the enum data and use that.

I don't think this matters right now, since the numeric translations
haven't changed, but it is the RigthThing(tm) to do.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-29 21:45:06 -07:00
Anton Lundin
cba786df2f Fix deco model strings in hw parser
The new version of the log book format broke the string handling.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-20 08:24:13 -07:00
Anton Lundin
4527c77a6b Add strings as extradata in xml
This teaches the dctool about the subsurface special field strings, and
saves them in the xml output in a way which is compatible with
subsurface.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-08-20 08:24:02 -07:00
Linus Torvalds
406dbf3dae Add severity indication to the event flags for the Suunto EON Steel
This way Subsurface can show different icons depending on what kind of
event we report.

This also fixes a bug where the begin/end marker was mistakenly added as
the value instead of as flag.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-23 17:07:38 +09:00
Linus Torvalds
8fb4018db3 Suunto EON Steel: add transmitter battery state reporting
I'm not sure how reliable it is, and older wireless tank pods had a bug
in the reporting (looks like the battery voltage range calibration was
done incorrectly, and it reports 0% battery for new batteries).

But depending on how well it actually works when the batteries start
getting weak, the transmitter battery reporting is potentially *very*
useful.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
8eb1c1232e Suunto EON Steel: add surface time reporting
For some reason I hadn't reported surface time.  It's trivial to do
especially now that we have the varargs string adding function.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
7fe87f36b5 Suunto EON Steel: split out gas info parsing
The dive gas parsing cases can be split out into a helper function to
keep things more manageable.  Especially since there will be a couple
more cases coming up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
4599405078 Suunto EON Steel: add 'varargs' version of 'add_string()' function
.. and use it for the cases that used to do this by hand (Personal
Adjustment and Desaturation Time).

There will be more users coming up.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
69d26e00b0 Suunto EON Steel: add desaturation time reporting
The EON Steel reports it in seconds remaining after the dive.  That's a
bit excessive, but I guess SI units is where it's at.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
5d4e1f97db Suunto EON Steel: add dive state event reporting
Now that we support string events and don't need to try to figure out
some libdivecomputer event number that doesn't exist, it's easy to add
the proper support for the dive state reporting that the EON Steel has.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
3547c72111 EON Steel: look up enum descriptor strings
It turns out you can't hardcode the enum numbers either, since they
change from dive to dive (or possibly firmware version to firmware
version).

So do it right, and actually parse the string descriptor for the enum.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
1b5ccf5983 EON Steel: pass in the type descriptor to samples that need it
The samples that take 'enum' types need the type descriptor to parse
what the enum type means.

This doesn't actually use the data yet, I need to add parsing of the
enum descriptor string.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
79e2e3b0b5 Add 'string' event type
The event numbers are an indecipherable mess, and Suunto EON Steel has
notifications, events and warnings that just don't fit.  Plus they
really come as strings from the EON Steel anyway.

So add a "SAMPLE_EVENT_STRING" type, and for that type the event has a
"const char *name" instead of the odd and meaningless flags/value pair.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
2e26ae4708 Make the tank "type" field more useful
Right now it only has an indication of whether the cylinder size is
imperial or metric, which is frankly quite useless.

Turn it into a bitmask instead, where we keep the imperial/metric data
for compatibility, but add another two bits that say that it's a CC
cylinder, and whether it's the oxygen or diluent cylinder.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-21 19:58:29 +09:00
Linus Torvalds
f38e8fe9ee EON Steel: mark tank cache initialized when filling it in
The previous commit fixed the cache initialization testing, and
uncovered the fact that the tank size cache initialization didn't set
the initialized bit correctly.  That oversight had been hidden by the
fact that we then tested the bit wrongly, so not setting it right didn't
use to matter as long as there were other higher cache bits that were
set.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-17 12:07:39 +09:00
Linus Torvalds
0aeae321dc EON Steel: fix uninitialized field cache entries
The check for whether we had initialized a field in the EON Steel cache
data structure was wrong, causing some entries to be returned
successfully even if their field had never been initialized.

In most cases, it didn't matter, since the cache data was initialized to
zero (which is a fine default for uninitialized data), so most of the
time it didn't matter.

But for the recently added dive mode field, this caused OC dives to be
returned as freedives, for example.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-07-16 15:58:57 +09:00
Linus Torvalds
de7ed23bec Initial Suunto EON Steel CCR support
This does the basic divemode and setpoint parsing for the EON Steel, and
gets the CCR download right in the big picture.

The cylinder information is still confusing and incorrect, but this is a
big step in the right direction.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-21 13:08:09 -07:00
Linus Torvalds
341b7c2dad Suunto EON Steel: add descriptor debugging output
.. every time I look for a new feature I add debug code to print out all
the descriptors.  So let's just do it once and for all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-06-21 13:08:03 -07:00
Dirk Hohndel
26b027cad8 Merge branch 'partsOfMaster' into Subsurface-branch 2016-06-12 23:10:48 -07:00
Jef Driesen
5361bc06bd Fix the nitrox gas mix parsing.
Mares Darwin compatible devices support a nitrox mode. The nitrogen
percentage should only be taken into account when the dive mode is set
to nitrox, because the last used value remains in place for air dives.
2016-06-12 23:10:37 -07:00
Jef Driesen
87facc940b Add support for the dive mode field. 2016-06-12 23:10:22 -07:00
Jef Driesen
bdc1c1349e Fix the length of the Vyper Novo gas change event.
Just like the Suunto DX, the Vyper Novo uses 5 bytes for the 0x06 gas
change event.
2016-06-12 23:09:54 -07:00
Jef Driesen
f67bdcd080 Add support for the Aqualung i300. 2016-06-12 23:09:43 -07:00
Dirk Hohndel
2015546952 Merge branch 'master' into Subsurface-branch 2016-04-26 09:35:06 -07:00
Dirk Hohndel
480e54ace7 Fix OSTC3 merge errors
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-19 17:37:25 -07:00
Dirk Hohndel
ecebda3b19 Fix Shearwater breakage caused by bad merging
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-18 05:55:12 -07:00
Miika Turkia
6c6752d87e Add dummy serial number usage to dctool
After adding support for serial number on dc parsers on
libdivecomputer's Subsurface branch, we need to add the serial parameter
to parser calls as well. Just using 0...

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-16 08:32:14 -07:00
Dirk Hohndel
8356e22e61 Merge branch 'master' into Subsurface-branch 2016-04-09 08:29:44 -07:00
Dirk Hohndel
515dc17914 Fix merge error that causes double free when downloading from EON Steel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-30 19:51:25 -05:00
Jef Driesen
cb0584adc1 Get the gas mixes from the sample data.
The Shearwater devices support adding, removing or editing gas mixes
during the dive. The pre-defined gas mixes available in the opening and
closing block are only a snapshot of the configuration at the start and
at the end of the dive. Thus by editing the gas mixes during the dive
it's possible to switch to a gas mix that is not present in the opening
(or even the closing block). The parser doesn't support that.

To avoid this problem, we now collect the available gas mixes from the
sample data. As a side effect we only return those gas mixes that are
effectively used during the dive.
2016-03-23 14:47:09 -07:00
Jef Driesen
f37b4b06db Cache the dive mode internally.
This simply moves the code to the get the dive mode from its own
function into the existing caching function.
2016-03-23 14:47:09 -07:00
Jef Driesen
aa2f670224 Add support for the Shearwater Perdix. 2016-03-23 14:47:09 -07:00
John Van Ostrand
af30fbb3f8 Add support for the Cochran Commander and EMC. 2016-03-23 14:47:09 -07:00
Dirk Hohndel
b13d8da426 Don't build examples by default
They are broken in this branch.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-23 14:47:09 -07:00
Jef Driesen
7f6348b066 Add support for the Uwatec Aladin Sport.
The Aladin Sport appears to be compatible with the Aladin 2G.
2016-03-23 14:47:09 -07:00
Jef Driesen
95d69ea30d Add support for the Suunto Zoop/Vyper Novo.
The Zoop Novo and Vyper Novo are compatible with respectively the D4i
and D6i.
2016-03-23 14:47:09 -07:00
Jef Driesen
cc12560b29 The new D6i data format support 3 gas mixes. 2016-03-23 14:47:09 -07:00
Jef Driesen
784844d8dd Add support for the new D4i and D6i data format.
One of the newer D4i and D6i firmware versions (for example v1.5.9),
introduces a new variant of the data format. The new dive header is 8
bytes larger. The correct variant can be detected by means of the
logbook id tag at the start of the header.
2016-03-23 14:47:09 -07:00
Jef Driesen
2fc31b72e7 Add support for the HW OSTC 4.
Except for the firmware update and a few other minor differences, the
new OSTC4 is backwards compatible with the OSTC3.
2016-03-23 14:47:08 -07:00
Jef Driesen
2e0db552ad Read and cache the hardware descriptor.
By reading the hardware descriptor immediately after entering download
or service mode, we can identify the specific model and adapt to minor
differences in the communication protocol.
2016-03-23 14:26:45 -07:00
Jef Driesen
6bb60bba31 Pass an array to the checksum function. 2016-03-23 14:25:14 -07:00
Dirk Hohndel
28f8cf6e19 Add configure option to disable checking for libusb and hidapi
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-06 10:05:45 -08:00
Dirk Hohndel
55a44a73bb One more merge fix
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-28 06:34:57 +01:00
Dirk Hohndel
7c33c633fb Merge branch 'master' into Subsurface-branch
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-02-27 22:17:36 +01:00
Dirk Hohndel
e227a4c5a7 Merge branch 'master' into Subsurface-branch 2015-12-14 09:33:53 -08:00
Dirk Hohndel
8bb373e514 Merge branch 'master' into Subsurface-branch 2015-12-07 09:48:39 -08:00
Dirk Hohndel
290f2781ea Merge branch 'master' into Subsurface-branch 2015-11-06 22:24:56 -08:00
Dirk Hohndel
4f321aef40 Merge branch 'master' into Subsurface-branch 2015-10-27 19:52:32 +09:00
Robert C. Helling
92a1919cf5 Mention Shearwater Nerd alongside with Petrel 2
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22 20:33:50 +09:00
Dirk Hohndel
2106cb2dab Add tank size reporting for Suunto EON Steel
Sadly the data we get from the EON Steel is a bit of a mess.
It doesn't really tell us if the data is metric or imperial (it always sends
both wet volume and working pressure). And in imperial mode the Suunto
engineers seem a bit confused. The pressure given (entered on the dive computer
in psi) is sent to us not in bar, not in atm... it's "something". As far as I
can tell it's a constant factor of 1.00069182389937 different from bar.
And the wet sizes are a bit to small to get the cuft size the user entered.
But instead of trying to guess and fix the mess, we just pass it through...

So this is somewhat useful, but not really what most users will want.

Linus started this commit with a few lines that parsed the right values out of
the data stream from the Suunto EON Steel. I then added the implementation of
the infrastructure to convert the raw data and report it back to the caller.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-22 20:29:43 +09:00
Anton Lundin
854f58fa32 Cleanup and correct CCR detection
== has precedence over & and would have needed some parenthesis.

Instead of that, this moves that code into the block below which
already contains a correct CCR check.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-18 16:43:15 -07:00
Dirk Hohndel
058538e628 Use hidapi for Suunto EON Steel on Mac
libusb on Mac doesn't support HID devices.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-18 10:39:55 -07:00
Anton Lundin
138fd856bd Add deco model info strings to shearwater parser
This adds two strings describing the deco model information of the dive.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-14 05:52:53 -07:00
Dirk Hohndel
1ccf937aa3 Merge branch 'master' into Subsurface-branch 2015-10-13 19:23:32 -07:00
Dirk Hohndel
da0073c971 Merge branch 'master' into Subsurface-branch 2015-10-02 06:18:51 -04:00
Claudiu Olteanu
8932b2a936 Fix dc_serial_native_open return check for Shearwater family
The dc_serial_native_open method doesn't return -1 on failures.
The failure errors can be DC_STATUS_INVALIDARGS, DC_STATUS_NOMEMORY,
DC_STATUS_IO.

Therefore we should check if the returned value is equal to
DC_STATUS_SUCCESS and pass it further.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-07 07:33:51 -07:00
Dirk Hohndel
9c7d1102d4 Fix compile errors on Mac
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-04 10:43:37 -07:00
Claudiu Olteanu
ad4bcffa23 Use custom set_timeout callback for Shearwater family
Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:47 -07:00
Claudiu Olteanu
f103553df1 Use the custom set_timeout callback for HW_OSTC 3 family
Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:38 -07:00
Claudiu Olteanu
a6274a3a55 Add set_timeout callback for serial custom implementation
The new callback will be usefull when we will implement the support
for Windows. The implementation of native serial set_timeout method
uses a HANDLER on Windows and we will use the WinSock2 API which has
a socket descriptor.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:32 -07:00
Gaetan Bisson
adfff2d4a7 Add new functions to list of exported symbols
This is required in order to build those new public functions into the
shared library.

Signed-off-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:25 -07:00
Linus Torvalds
f0e695b089 EON Steel: expose the gas switch cylinder in the "flags" field
This seems to be the simplest extension to the SAMPLE_EVENT_GASCHANGE2
format: the "value" remains the oddly encoded gas mix, but the "flags"
value (if non-zero) now contains the actual cylinder number we switch
to.

This will need a trivial patch to subsurface to take advantage of the
new data too.  But then we can actually distinguish between cylinders
that have the same gas mix.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:09 -07:00
Linus Torvalds
fe2448e34f Add EON Steel personal adjustment parsing
Suunto calls it "Conservatism" in the dump, but "Personal adjustment" in
at least some of the documentation. That's what we expose it as.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:48:00 -07:00
Linus Torvalds
7fd201a400 Add EON Steel dive mode and transmitter ID information
This adds the divemode name (Nitrox, Trimix, Gauge, or whatever custon
name) and the transmitter ID as extra string information when
downloading from the EON Steel.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:54 -07:00
Linus Torvalds
c39dda89bc Suunto EON Steel: populate various string data
The EON Steel saves the dive computer firmware versions etc per dive,
which is really nice for upgrades: old dives done with older firmware
still show the firmware at the time of the dive.  That, in turn, is nice
because we can use it for a reliable dive ID - dive time with serial
number etc.

This uses the new DC_FIELD_STRING model to feed the hw/sw information to
the application, since we need the parser to access it.  It also returns
battery state and deco model information.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:48 -07:00
Claudiu Olteanu
0c8886ce70 Implement custom open device method for SHEARWATER family
Create a custom open method for SHEARWATER family.
This method can be used to pass a reference to a dc_serial_t
structure. In this way the applications can implement their
own implementation for a serial communication and set their
callbacks for the basic serial functions.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
53ccc4f43b Use the dc_serial_t structure in SHEARWATER family
Use the new structure in the SHEARWATER family implementation.
This patch opens a native serial device and use it
for the serial communication.

Also the patch uses the set of callback functions saved in the
dc_serial_t structure.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
8c3e44aa0c Implement custom device open method
This method can be used by external applications to open a
device and to pass their custom implementation for the
serial communication.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
5dbaa7a053 Implement custom open method for HW OSTC 3 family
Create a custom open method for HW OSTC3 family.
This method can be used to pass a reference to a dc_serial_t
structure. In this way the applications can implement their
own implementation for a serial communication and set their
callbacks for the basic serial functions.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
69bd993233 Use the dc_serial_t structure in HW OSTC family 3
Open a native serial device and use it in the HW OSTC3
implementation.

This patch replaces the old serial structure with the
new one, which can be used for custom serial implementations.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
a50a1e0688 Create a generic way to represent any type of serial communication
Add a structure which holds references to basic operations
on a serial communication. This can be used to pass a set
of function pointer callbacks in order to create a custom
implementation for serial communication.

Add a generic structure to represent the needed information
for a serial communication.

Implement the initialization method where the user can
pass a set of function pointer callbacks and set some
custom data for the serial device.

Create open method for the native serial implementation.

Signed-off-by: Claudiu Olteanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Claudiu Olteanu
b9e3f40d59 Extend the transport enum descriptor for serial communication
Add a new transport type which can be used to identify
Bluetooth serial communication.

Signed-off-by Claudiu Oleanu <olteanu.claudiu@ymail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Anton Lundin
f184b45e09 Correct firmware version string from OSTC's
The format string was incorrect, producing firmware numbers as 3.2
instead of 3.02 as is the current OSTC firmware version.

This was reported via hw's forum:
http://forum.heinrichsweikamp.com/read.php?2,14550,14552

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Dirk Hohndel
0ff1dd15f5 Predator: don't report PPO2 unless in CC mode
Sending this in OC mode is redundant and might confuse applications that
assume they only get PPO2 data in CC mode.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Dirk Hohndel
fb15ef18f6 Don't report errors if we can't set serial mode
That's just silly and breaks using the simulator.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Anton Lundin
3a17156be6 Add deco model info strings to hw parser
Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:33 -07:00
Dirk Hohndel
1f24f67565 Make it easier to detect our branch of libdivecomputer
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:47:18 -07:00
Dirk Hohndel
5ecc65799c Mark a library built from our branch as such
This way it will be obvious when people report their libdivecomputer
version that they are using our branch

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:46:55 -07:00
Linus Torvalds
ddfdb6c306 Fix suunto serial numbers
libdivecomputer has already done the "byte to decimal" conversion.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:41:50 -07:00
Dirk Hohndel
b85f2333be Support serial number for Suuntu Vyper2 family of devices
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.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:41:43 -07:00
Dirk Hohndel
06426af656 Support firmware and serial number for Shearwater Petrel
This should work with the Predator as well.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:41:20 -07:00
Dirk Hohndel
f459155b54 Support serial number as DC_FIELD_STRING on atom2 backend
This has been verified with a few of the models, it needs much more
testing to make sure this is generally correct.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:40:35 -07:00
Dirk Hohndel
ebe6704747 Add support to return serial number to OSTC devices
This data isn't per dive, but it makes sense to return it here as a
string (we already return it as unsigned int in the devinfo event after
opening the device).

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:40:09 -07:00
Dirk Hohndel
5f76249923 Pass the serial number from the devinfo to the OSTC parsers
This way we can analyze the data in the parser and return it to the
application.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:39:52 -07:00
Dirk Hohndel
0ddec2b50f Support FW Version on OSTC devices
And add battery voltage and desat for the Frog.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:39:45 -07:00
Dirk Hohndel
8f4038d4cd Add DC_FIELD_STRING support to OSTC parser
Just support a few of the most useful values. There are several more we
could and should add.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:39:36 -07:00
Dirk Hohndel
d90417da38 Add DC_FIELD_STRING support to Shearwater Petrel parser
Just support a few of the most useful values. There are several more we
could and should add.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:14:57 -07:00
Dirk Hohndel
f902f5882c Add DC_FIELD_STRING support to Atomics Aquatics Cobalt parser
Just support a few of the most useful values. There are several more we
could and should add.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:14:09 -07:00
Linus Torvalds
eac8e98ee7 parser: add DC_FIELD_STRING field type for parse-time information
This can be used to return almost arbitrary information to the dive log
application at dive parse time, by returning a number of strings (with a
descriptor) for dive state.

NOTE! The strings are supposed to be human-readable, so that the dive
log application can just show them unedited - and without understanding
them - to the user, together with the description.  So if your dive
computer supports returning a battery voltage, for example, you can
return it as a

  { "Voltage", "4.449V" }

descriptor/value string pair, and the application could then put these
string pairs together and show (somewhere) an informational line like
"Voltage: 4.449V" along with the other information you return.

Some dive log applications migth recognize particular descriptor strings
and use them specially to fill in other information (ie serial numbers,
weight and suit information etc), but in general the interface is very
much meant to be informational free-form for a human user.

So do *not* use this interface to encode things that are not human-
readable.  Serial numbers or version information that is meaningful to
humans are fine. But random encoded data structures are not.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-26 10:13:51 -07:00
273 changed files with 8934 additions and 32091 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 }}

32
.gitignore vendored
View File

@ -37,7 +37,32 @@ Makefile.in
/doc/html/ /doc/html/
/doc/latex/ /doc/latex/
/examples/dctool /examples/aladin
/examples/atom2
/examples/d9
/examples/darwin
/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 +72,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

@ -1,55 +0,0 @@
language: c
matrix:
include:
- os: linux
compiler: gcc
- os: linux
compiler: clang
- os: osx
compiler: gcc
- os: osx
compiler: clang
- os: linux
compiler: i686-w64-mingw32-gcc
addons:
apt:
packages:
- gcc-mingw-w64
- binutils-mingw-w64
- mingw-w64-tools
- os: linux
compiler: x86_64-w64-mingw32-gcc
addons:
apt:
packages:
- gcc-mingw-w64
- binutils-mingw-w64
- mingw-w64-tools
addons:
apt:
packages:
- libbluetooth-dev
- libusb-1.0-0-dev
homebrew:
packages:
- hidapi
- libusb
script:
- case $CC in
*-gcc) TARGET="${CC%-gcc}" ;;
esac
- if [ -n "$TARGET" ]; then
TARGETOPTS="--host=${TARGET}";
unset CC;
fi
- autoreconf --install --force
- ./configure $TARGETOPTS --disable-doc
- make

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,8 +1,8 @@
# 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-branch])
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]))
# Libtool versioning. # Libtool versioning.
@ -60,6 +60,15 @@ AC_ARG_ENABLE([doc],
[], [enable_doc=yes]) [], [enable_doc=yes])
AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"]) AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"])
# BLE support
AC_ARG_ENABLE([ble],
[AS_HELP_STRING([--enable-ble=@<:@yes/no@:>@],
[Enable BLE dive computers @<:@default=yes@:>@])],
[], [enable_ble=no])
AS_IF([test "x$enable_ble" = "xyes"], [
AC_DEFINE(ENABLE_BLE, [1], [Enable support for BLE dive computers.])
])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_C99 AC_PROG_CC_C99
@ -72,21 +81,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 +109,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,10 +163,9 @@ 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])
# Checks for global variable declarations. # Checks for global variable declarations.
AC_CHECK_DECLS([optreset]) AC_CHECK_DECLS([optreset])
@ -186,35 +178,21 @@ AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[
# Checks for library functions. # Checks for library functions.
AC_FUNC_STRERROR_R AC_FUNC_STRERROR_R
AC_CHECK_FUNCS([localtime_r gmtime_r timegm _mkgmtime]) AC_CHECK_FUNCS([localtime_r gmtime_r timegm _mkgmtime])
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 \
-Wrestrict \ -Wrestrict \
-Wformat=2 \ -Wformat=2 \
-Wwrite-strings \ -Wwrite-strings \
-Wcast-qual \
-Wpointer-arith \ -Wpointer-arith \
-Wstrict-prototypes \ -Wstrict-prototypes \
-Wmissing-prototypes \ -Wmissing-prototypes \
-Wmissing-declarations \ -Wmissing-declarations \
-Wno-unused-parameter \ -Wno-unused-parameter \
-Wno-unused-function \
-Wno-unused-variable \
-Wno-unused-but-set-variable \
-Wno-pointer-sign \
-Wno-shadow \
-Wenum-conversion \
-Werror=enum-conversion \
-fmacro-prefix-map='$(top_srcdir)/'= \
],,[$ERROR_CFLAGS])
# Windows specific compiler options.
AS_IF([test "$platform" = "windows"], [
AX_APPEND_COMPILE_FLAGS([-Wno-pedantic-ms-format])
]) ])
# Versioning. # Versioning.
@ -229,25 +207,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 +214,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 +0,0 @@
# Atomic Aquatics Cobalt
SUBSYSTEM=="usb", ATTR{idVendor}=="0471", ATTR{idProduct}=="0888", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0471", ATTRS{idProduct}=="0888", GROUP="plugdev"
# Suunto EON Steel
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0030", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0030", GROUP="plugdev"
# Suunto EON Core
SUBSYSTEM=="usb", ATTR{idVendor}=="1493", ATTR{idProduct}=="0033", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1493", ATTRS{idProduct}=="0033", GROUP="plugdev"
# Suunto D5
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
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3201", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="3201", GROUP="plugdev"
# Scubapro G2 Console
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="3211", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="3211", GROUP="plugdev"
# Scubapro G2 HUD
SUBSYSTEM=="usb", ATTR{idVendor}=="2e6c", ATTR{idProduct}=="4201", GROUP="plugdev"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="2e6c", ATTRS{idProduct}=="4201", GROUP="plugdev"
# Scubapro Aladin Square
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

@ -14,10 +14,8 @@ MANPAGES = \
dc_datetime_mktime.3 \ dc_datetime_mktime.3 \
dc_datetime_now.3 \ dc_datetime_now.3 \
dc_descriptor_free.3 \ dc_descriptor_free.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,29 +30,8 @@ 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 \ libdivecomputer.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
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,60 +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_IOSTREAM_CLOSE 3
.Os
.Sh NAME
.Nm dc_iostream_close
.Nd Close the I/O stream and free all resources.
.Sh LIBRARY
.Lb libdivecomputer
.Sh SYNOPSIS
.In libdivecomputer/iostream.h
.Ft dc_status_t
.Fo dc_iostream_close
.Fa "dc_iostream_t *iostream"
.Fc
.Sh DESCRIPTION
Close the I/O stream and free all resources.
Accepts the
.Fa iostream
to close and free.
.Sh RETURN VALUES
Returns
.Dv DC_STATUS_SUCCESS
on success, or another
.Ft dc_status_t
code on failure.
.Sh SEE ALSO
.Xr dc_usbhid_open 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

@ -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,8 +1,7 @@
.\" .\"
.\" libdivecomputer .\" libdivecomputer
.\" .\"
.\" Copyright (C) 2018 Kristaps Dzonsons <kristaps@bsd.lv> .\" 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
@ -19,28 +18,42 @@
.\" 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 August 19, 2018 .Dd January 5, 2017
.Dt DC_DESCRIPTOR_GET_MODEL 3 .Dt DC_PARSER_SET_DATA 3
.Os .Os
.Sh NAME .Sh NAME
.Nm dc_descriptor_get_model .Nm dc_parser_set_data
.Nd get the model of a dive computer descriptor .Nd assigns parse data to a dive parser
.Sh LIBRARY .Sh LIBRARY
.Lb libdivecomputer .Lb libdivecomputer
.Sh SYNOPSIS .Sh SYNOPSIS
.In libdivecomputer/descriptor.h .In libdivecomputer/parser.h
.Ft "unsigned int" .Ft dc_status_t
.Fo dc_descriptor_get_model .Fo dc_parser_set_data
.Fa "dc_descriptor_t *descriptor" .Fa "dc_parser_t *parser"
.Fa "const unsigned char *data"
.Fa "unsigned int size"
.Fc .Fc
.Sh DESCRIPTION .Sh DESCRIPTION
Gets the model number of a dive computer descriptor or 0 if none was Assigns the binary sequence
defined for the computer. .Fa data
0 is also a valid model number. of length
.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
This returns the model number or 0 if none exists. Returns
.Dv DC_STATUS_OK
on success and another code on failure.
.Sh SEE ALSO .Sh SEE ALSO
.Xr dc_descriptor_iterator 3 .Xr dc_device_foreach 3 ,
.Xr dc_parser_new 3
.Sh AUTHORS .Sh AUTHORS
The The
.Lb libdivecomputer .Lb libdivecomputer

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

@ -12,7 +12,6 @@ dctool_SOURCES = \
dctool_help.c \ dctool_help.c \
dctool_version.c \ dctool_version.c \
dctool_list.c \ dctool_list.c \
dctool_scan.c \
dctool_download.c \ dctool_download.c \
dctool_dump.c \ dctool_dump.c \
dctool_parse.c \ dctool_parse.c \

View File

@ -19,7 +19,6 @@
* MA 02110-1301 USA * MA 02110-1301 USA
*/ */
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -28,12 +27,6 @@
#include <fcntl.h> #include <fcntl.h>
#endif #endif
#include <libdivecomputer/serial.h>
#include <libdivecomputer/bluetooth.h>
#include <libdivecomputer/irda.h>
#include <libdivecomputer/usb.h>
#include <libdivecomputer/usbhid.h>
#include "common.h" #include "common.h"
#include "utils.h" #include "utils.h"
@ -51,11 +44,6 @@ typedef struct backend_table_t {
unsigned int model; unsigned int model;
} backend_table_t; } backend_table_t;
typedef struct transport_table_t {
const char *name;
dc_transport_t type;
} transport_table_t;
static const backend_table_t g_backends[] = { static const backend_table_t g_backends[] = {
{"solution", DC_FAMILY_SUUNTO_SOLUTION, 0}, {"solution", DC_FAMILY_SUUNTO_SOLUTION, 0},
{"eon", DC_FAMILY_SUUNTO_EON, 0}, {"eon", DC_FAMILY_SUUNTO_EON, 0},
@ -66,13 +54,14 @@ static const backend_table_t g_backends[] = {
{"aladin", DC_FAMILY_UWATEC_ALADIN, 0x3F}, {"aladin", DC_FAMILY_UWATEC_ALADIN, 0x3F},
{"memomouse", DC_FAMILY_UWATEC_MEMOMOUSE, 0}, {"memomouse", DC_FAMILY_UWATEC_MEMOMOUSE, 0},
{"smart", DC_FAMILY_UWATEC_SMART, 0x10}, {"smart", DC_FAMILY_UWATEC_SMART, 0x10},
{"meridian", DC_FAMILY_UWATEC_MERIDIAN, 0x20},
{"g2", DC_FAMILY_UWATEC_G2, 0x11},
{"sensus", DC_FAMILY_REEFNET_SENSUS, 1}, {"sensus", DC_FAMILY_REEFNET_SENSUS, 1},
{"sensuspro", DC_FAMILY_REEFNET_SENSUSPRO, 2}, {"sensuspro", DC_FAMILY_REEFNET_SENSUSPRO, 2},
{"sensusultra", DC_FAMILY_REEFNET_SENSUSULTRA, 3}, {"sensusultra", DC_FAMILY_REEFNET_SENSUSULTRA, 3},
{"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},
@ -82,7 +71,6 @@ static const backend_table_t g_backends[] = {
{"ostc3", DC_FAMILY_HW_OSTC3, 0x0A}, {"ostc3", DC_FAMILY_HW_OSTC3, 0x0A},
{"edy", DC_FAMILY_CRESSI_EDY, 0x08}, {"edy", DC_FAMILY_CRESSI_EDY, 0x08},
{"leonardo", DC_FAMILY_CRESSI_LEONARDO, 1}, {"leonardo", DC_FAMILY_CRESSI_LEONARDO, 1},
{"goa", DC_FAMILY_CRESSI_GOA, 2},
{"n2ition3", DC_FAMILY_ZEAGLE_N2ITION3, 0}, {"n2ition3", DC_FAMILY_ZEAGLE_N2ITION3, 0},
{"cobalt", DC_FAMILY_ATOMICS_COBALT, 0}, {"cobalt", DC_FAMILY_ATOMICS_COBALT, 0},
{"predator", DC_FAMILY_SHEARWATER_PREDATOR, 2}, {"predator", DC_FAMILY_SHEARWATER_PREDATOR, 2},
@ -91,30 +79,6 @@ static const backend_table_t g_backends[] = {
{"aqualand", DC_FAMILY_CITIZEN_AQUALAND, 0}, {"aqualand", DC_FAMILY_CITIZEN_AQUALAND, 0},
{"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},
{"extreme", DC_FAMILY_MCLEAN_EXTREME, 0},
{"lynx", DC_FAMILY_LIQUIVISION_LYNX, 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[] = {
{"serial", DC_TRANSPORT_SERIAL},
{"usb", DC_TRANSPORT_USB},
{"usbhid", DC_TRANSPORT_USBHID},
{"irda", DC_TRANSPORT_IRDA},
{"bluetooth", DC_TRANSPORT_BLUETOOTH},
{"ble", DC_TRANSPORT_BLE},
// Not merged upstream yet
{"usbstorage",DC_TRANSPORT_USBSTORAGE},
}; };
const char * const char *
@ -181,41 +145,6 @@ dctool_family_model (dc_family_t type)
return 0; return 0;
} }
dc_transport_t
dctool_transport_type (const char *name)
{
for (size_t i = 0; i < C_ARRAY_SIZE (g_transports); ++i) {
if (strcmp (name, g_transports[i].name) == 0)
return g_transports[i].type;
}
return DC_TRANSPORT_NONE;
}
const char *
dctool_transport_name (dc_transport_t type)
{
for (size_t i = 0; i < C_ARRAY_SIZE (g_transports); ++i) {
if (g_transports[i].type == type)
return g_transports[i].name;
}
return NULL;
}
dc_transport_t
dctool_transport_default (dc_descriptor_t *descriptor)
{
unsigned int transports = dc_descriptor_get_transports (descriptor);
for (size_t i = 0; i < C_ARRAY_SIZE (g_transports); ++i) {
if (transports & g_transports[i].type)
return g_transports[i].type;
}
return DC_TRANSPORT_NONE;
}
void void
dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata) dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
{ {
@ -411,188 +340,3 @@ 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
dctool_usbhid_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 usbhid device.
dc_iterator_t *iterator = NULL;
dc_usbhid_device_t *device = NULL;
dc_usbhid_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 usbhid device.
status = dc_usbhid_open (&iostream, context, device);
if (status != DC_STATUS_SUCCESS) {
ERROR ("Failed to open the usbhid device.");
goto cleanup;
}
*out = iostream;
cleanup:
dc_usbhid_device_free (device);
return status;
}
static dc_status_t
dctool_irda_open (dc_iostream_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *devname)
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
unsigned int address = 0;
if (devname) {
// Use the address.
address = strtoul(devname, NULL, 0);
} else {
// Discover the device address.
dc_iterator_t *iterator = NULL;
dc_irda_device_t *device = NULL;
dc_irda_iterator_new (&iterator, context, descriptor);
while (dc_iterator_next (iterator, &device) == DC_STATUS_SUCCESS) {
address = dc_irda_device_get_address (device);
dc_irda_device_free (device);
break;
}
dc_iterator_free (iterator);
}
if (address == 0) {
if (devname) {
ERROR ("No valid device address specified.");
} else {
ERROR ("No dive computer found.");
}
status = DC_STATUS_NODEVICE;
goto cleanup;
}
// Open the irda socket.
status = dc_irda_open (&iostream, context, address, 1);
if (status != DC_STATUS_SUCCESS) {
ERROR ("Failed to open the irda socket.");
goto cleanup;
}
*out = iostream;
cleanup:
return status;
}
static dc_status_t
dctool_bluetooth_open (dc_iostream_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *devname)
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_bluetooth_address_t address = 0;
if (devname) {
// Use the address.
address = dc_bluetooth_str2addr(devname);
} else {
// Discover the device address.
dc_iterator_t *iterator = NULL;
dc_bluetooth_device_t *device = NULL;
dc_bluetooth_iterator_new (&iterator, context, descriptor);
while (dc_iterator_next (iterator, &device) == DC_STATUS_SUCCESS) {
address = dc_bluetooth_device_get_address (device);
dc_bluetooth_device_free (device);
break;
}
dc_iterator_free (iterator);
}
if (address == 0) {
if (devname) {
ERROR ("No valid device address specified.");
} else {
ERROR ("No dive computer found.");
}
status = DC_STATUS_NODEVICE;
goto cleanup;
}
// Open the bluetooth socket.
status = dc_bluetooth_open (&iostream, context, address, 0);
if (status != DC_STATUS_SUCCESS) {
ERROR ("Failed to open the bluetooth socket.");
goto cleanup;
}
*out = iostream;
cleanup:
return status;
}
dc_status_t
dctool_iostream_open (dc_iostream_t **iostream, dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname)
{
switch (transport) {
case DC_TRANSPORT_SERIAL:
return dc_serial_open (iostream, context, devname);
case DC_TRANSPORT_USB:
return dctool_usb_open(iostream, context, descriptor);
case DC_TRANSPORT_USBHID:
return dctool_usbhid_open(iostream, context, descriptor);
case DC_TRANSPORT_IRDA:
return dctool_irda_open (iostream, context, descriptor, devname);
case DC_TRANSPORT_BLUETOOTH:
return dctool_bluetooth_open (iostream, context, descriptor, devname);
default:
return DC_STATUS_UNSUPPORTED;
// Not merged upstream yet
case DC_TRANSPORT_USBSTORAGE:
return dc_usb_storage_open (iostream, context, devname);
}
}

View File

@ -24,7 +24,6 @@
#include <libdivecomputer/context.h> #include <libdivecomputer/context.h>
#include <libdivecomputer/descriptor.h> #include <libdivecomputer/descriptor.h>
#include <libdivecomputer/iostream.h>
#include <libdivecomputer/device.h> #include <libdivecomputer/device.h>
#ifdef __cplusplus #ifdef __cplusplus
@ -43,15 +42,6 @@ dctool_family_name (dc_family_t type);
unsigned int unsigned int
dctool_family_model (dc_family_t type); dctool_family_model (dc_family_t type);
dc_transport_t
dctool_transport_type (const char *name);
const char *
dctool_transport_name (dc_transport_t type);
dc_transport_t
dctool_transport_default (dc_descriptor_t *descriptor);
void void
dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata); dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata);
@ -67,9 +57,6 @@ dctool_file_write (const char *filename, dc_buffer_t *buffer);
dc_buffer_t * dc_buffer_t *
dctool_file_read (const char *filename); dctool_file_read (const char *filename);
dc_status_t
dctool_iostream_open (dc_iostream_t **iostream, dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

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 ""
@ -60,7 +58,6 @@ static const dctool_command_t *g_commands[] = {
&dctool_help, &dctool_help,
&dctool_version, &dctool_version,
&dctool_list, &dctool_list,
&dctool_scan,
&dctool_download, &dctool_download,
&dctool_dump, &dctool_dump,
&dctool_parse, &dctool_parse,
@ -242,8 +239,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];
@ -279,7 +275,14 @@ main (int argc, char *argv[])
dc_context_set_loglevel (context, loglevel); dc_context_set_loglevel (context, loglevel);
dc_context_set_logfunc (context, logfunc, NULL); dc_context_set_logfunc (context, logfunc, NULL);
if (device != NULL || family != DC_FAMILY_NULL) { if (command->config & DCTOOL_CONFIG_DESCRIPTOR) {
// Check mandatory arguments.
if (device == NULL && family == DC_FAMILY_NULL) {
message ("No device name or family type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Search for a matching device descriptor. // Search for a matching device descriptor.
status = dctool_descriptor_search (&descriptor, device, family, model); status = dctool_descriptor_search (&descriptor, device, family, model);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
@ -301,13 +304,6 @@ main (int argc, char *argv[])
} }
} }
// Check mandatory descriptor arguments.
if (command->config & DCTOOL_CONFIG_DESCRIPTOR && descriptor == NULL) {
message ("No device name or family type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Execute the command. // Execute the command.
exitcode = command->run (argc, argv, context, descriptor); exitcode = command->run (argc, argv, context, descriptor);

View File

@ -45,7 +45,6 @@ typedef struct dctool_command_t {
extern const dctool_command_t dctool_help; extern const dctool_command_t dctool_help;
extern const dctool_command_t dctool_version; extern const dctool_command_t dctool_version;
extern const dctool_command_t dctool_list; extern const dctool_command_t dctool_list;
extern const dctool_command_t dctool_scan;
extern const dctool_command_t dctool_download; extern const dctool_command_t dctool_download;
extern const dctool_command_t dctool_dump; extern const dctool_command_t dctool_dump;
extern const dctool_command_t dctool_parse; extern const dctool_command_t dctool_parse;

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);
@ -146,28 +152,18 @@ event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *us
} }
static dc_status_t static dc_status_t
download (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const char *cachedir, dc_buffer_t *fingerprint, dctool_output_t *output) download (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, const char *cachedir, dc_buffer_t *fingerprint, dctool_output_t *output)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
dc_buffer_t *ofingerprint = NULL; dc_buffer_t *ofingerprint = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -240,7 +236,6 @@ download (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t tra
cleanup: cleanup:
dc_buffer_free (ofingerprint); dc_buffer_free (ofingerprint);
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -252,7 +247,6 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
dc_buffer_t *fingerprint = NULL; dc_buffer_t *fingerprint = NULL;
dctool_output_t *output = NULL; dctool_output_t *output = NULL;
dctool_units_t units = DCTOOL_UNITS_METRIC; dctool_units_t units = DCTOOL_UNITS_METRIC;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
@ -263,11 +257,10 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:o:p:c:f:u:"; const char *optstring = "ho:p:c:f:u:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{"output", required_argument, 0, 'o'}, {"output", required_argument, 0, 'o'},
{"fingerprint", required_argument, 0, 'p'}, {"fingerprint", required_argument, 0, 'p'},
{"cache", required_argument, 0, 'c'}, {"cache", required_argument, 0, 'c'},
@ -283,9 +276,6 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
case 'h': case 'h':
help = 1; help = 1;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
case 'o': case 'o':
filename = optarg; filename = optarg;
break; break;
@ -318,13 +308,6 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Convert the fingerprint to binary. // Convert the fingerprint to binary.
fingerprint = dctool_convert_hex2bin (fphex); fingerprint = dctool_convert_hex2bin (fphex);
@ -345,7 +328,7 @@ dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descripto
} }
// Download the dives. // Download the dives.
status = download (context, descriptor, transport, argv[0], cachedir, fingerprint, output); status = download (context, descriptor, argv[0], cachedir, fingerprint, output);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -369,7 +352,6 @@ const dctool_command_t dctool_download = {
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
" -o, --output <filename> Output filename\n" " -o, --output <filename> Output filename\n"
" -p, --fingerprint <data> Fingerprint data (hexadecimal)\n" " -p, --fingerprint <data> Fingerprint data (hexadecimal)\n"
" -c, --cache <directory> Cache directory\n" " -c, --cache <directory> Cache directory\n"
@ -377,7 +359,6 @@ const dctool_command_t dctool_download = {
" -u, --units <units> Set units (metric or imperial)\n" " -u, --units <units> Set units (metric or imperial)\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
" -o <filename> Output filename\n" " -o <filename> Output filename\n"
" -p <fingerprint> Fingerprint data (hexadecimal)\n" " -p <fingerprint> Fingerprint data (hexadecimal)\n"
" -c <directory> Cache directory\n" " -c <directory> Cache directory\n"

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
@ -42,27 +40,17 @@
#include "utils.h" #include "utils.h"
static dc_status_t static dc_status_t
dump (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, dc_buffer_t *fingerprint, dc_buffer_t *buffer) dump (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, dc_buffer_t *fingerprint, dc_buffer_t *buffer)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -105,7 +93,6 @@ dump (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transpo
cleanup: cleanup:
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -116,7 +103,6 @@ dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
dc_buffer_t *fingerprint = NULL; dc_buffer_t *fingerprint = NULL;
dc_buffer_t *buffer = NULL; dc_buffer_t *buffer = NULL;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
@ -125,11 +111,10 @@ dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:o:p:"; const char *optstring = "ho:p:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{"output", required_argument, 0, 'o'}, {"output", required_argument, 0, 'o'},
{"fingerprint", required_argument, 0, 'p'}, {"fingerprint", required_argument, 0, 'p'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
@ -142,9 +127,6 @@ dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
case 'h': case 'h':
help = 1; help = 1;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
case 'o': case 'o':
filename = optarg; filename = optarg;
break; break;
@ -165,13 +147,6 @@ dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Convert the fingerprint to binary. // Convert the fingerprint to binary.
fingerprint = dctool_convert_hex2bin (fphex); fingerprint = dctool_convert_hex2bin (fphex);
@ -179,7 +154,7 @@ dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
buffer = dc_buffer_new (0); buffer = dc_buffer_new (0);
// Download the memory dump. // Download the memory dump.
status = dump (context, descriptor, transport, argv[0], fingerprint, buffer); status = dump (context, descriptor, argv[0], fingerprint, buffer);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -206,12 +181,10 @@ const dctool_command_t dctool_dump = {
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
" -o, --output <filename> Output filename\n" " -o, --output <filename> Output filename\n"
" -p, --fingerprint <data> Fingerprint data (hexadecimal)\n" " -p, --fingerprint <data> Fingerprint data (hexadecimal)\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
" -o <filename> Output filename\n" " -o <filename> Output filename\n"
" -p <fingerprint> Fingerprint data (hexadecimal)\n" " -p <fingerprint> Fingerprint data (hexadecimal)\n"
#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
@ -37,34 +35,23 @@
#include <libdivecomputer/device.h> #include <libdivecomputer/device.h>
#include <libdivecomputer/hw_ostc.h> #include <libdivecomputer/hw_ostc.h>
#include <libdivecomputer/hw_ostc3.h> #include <libdivecomputer/hw_ostc3.h>
#include <libdivecomputer/divesystem_idive.h>
#include "dctool.h" #include "dctool.h"
#include "common.h" #include "common.h"
#include "utils.h" #include "utils.h"
static dc_status_t static dc_status_t
fwupdate (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const char *hexfile) fwupdate (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, const char *hexfile)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -94,10 +81,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;
case DC_FAMILY_DIVESYSTEM_IDIVE:
rc = divesystem_idive_device_fwupdate (device, hexfile);
break; break;
default: default:
rc = DC_STATUS_UNSUPPORTED; rc = DC_STATUS_UNSUPPORTED;
@ -110,7 +94,6 @@ fwupdate (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t tra
cleanup: cleanup:
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -119,7 +102,6 @@ dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descripto
{ {
int exitcode = EXIT_SUCCESS; int exitcode = EXIT_SUCCESS;
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
@ -127,11 +109,10 @@ dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descripto
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:f:"; const char *optstring = "hf:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{"firmware", required_argument, 0, 'f'}, {"firmware", required_argument, 0, 'f'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
@ -143,9 +124,6 @@ dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descripto
case 'f': case 'f':
filename = optarg; filename = optarg;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
case 'h': case 'h':
help = 1; help = 1;
break; break;
@ -163,13 +141,6 @@ dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descripto
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Check mandatory arguments. // Check mandatory arguments.
if (!filename) { if (!filename) {
message ("No firmware file specified.\n"); message ("No firmware file specified.\n");
@ -178,7 +149,7 @@ dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descripto
} }
// Update the firmware. // Update the firmware.
status = fwupdate (context, descriptor, transport, argv[0], filename); status = fwupdate (context, descriptor, argv[0], filename);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -200,11 +171,9 @@ const dctool_command_t dctool_fwupdate = {
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
" -f, --firmware <filename> Firmware filename\n" " -f, --firmware <filename> Firmware filename\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
" -f <filename> Firmware filename\n" " -f <filename> Firmware filename\n"
#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

@ -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
@ -41,27 +39,17 @@
#include "utils.h" #include "utils.h"
static dc_status_t static dc_status_t
doread (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, unsigned int address, dc_buffer_t *buffer) doread (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, unsigned int address, dc_buffer_t *buffer)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -94,7 +82,6 @@ doread (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t trans
cleanup: cleanup:
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -104,7 +91,6 @@ dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
int exitcode = EXIT_SUCCESS; int exitcode = EXIT_SUCCESS;
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
dc_buffer_t *buffer = NULL; dc_buffer_t *buffer = NULL;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
@ -114,11 +100,10 @@ dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:a:c:o:"; const char *optstring = "ha:c:o:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{"address", required_argument, 0, 'a'}, {"address", required_argument, 0, 'a'},
{"count", required_argument, 0, 'c'}, {"count", required_argument, 0, 'c'},
{"output", required_argument, 0, 'o'}, {"output", required_argument, 0, 'o'},
@ -132,9 +117,6 @@ dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
case 'h': case 'h':
help = 1; help = 1;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
case 'a': case 'a':
address = strtoul (optarg, NULL, 0); address = strtoul (optarg, NULL, 0);
have_address = 1; have_address = 1;
@ -160,13 +142,6 @@ dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Check mandatory arguments. // Check mandatory arguments.
if (!have_address || !have_count) { if (!have_address || !have_count) {
message ("No memory address or byte count specified.\n"); message ("No memory address or byte count specified.\n");
@ -184,7 +159,7 @@ dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
} }
// Read data from the internal memory. // Read data from the internal memory.
status = doread (context, descriptor, transport, argv[0], address, buffer); status = doread (context, descriptor, argv[0], address, buffer);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -210,13 +185,11 @@ const dctool_command_t dctool_read = {
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
" -a, --address <address> Memory address\n" " -a, --address <address> Memory address\n"
" -c, --count <count> Number of bytes\n" " -c, --count <count> Number of bytes\n"
" -o, --output <filename> Output filename\n" " -o, --output <filename> Output filename\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
" -a <address> Memory address\n" " -a <address> Memory address\n"
" -c <count> Number of bytes\n" " -c <count> Number of bytes\n"
" -o <filename> Output filename\n" " -o <filename> Output filename\n"

View File

@ -1,202 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2017 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
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#include <libdivecomputer/context.h>
#include <libdivecomputer/descriptor.h>
#include <libdivecomputer/iterator.h>
#include <libdivecomputer/serial.h>
#include <libdivecomputer/irda.h>
#include <libdivecomputer/bluetooth.h>
#include <libdivecomputer/usb.h>
#include <libdivecomputer/usbhid.h>
#include "dctool.h"
#include "common.h"
#include "utils.h"
static dc_status_t
scan (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport)
{
dc_status_t status = DC_STATUS_SUCCESS;
dc_iterator_t *iterator = NULL;
// Create the device iterator.
switch (transport) {
case DC_TRANSPORT_SERIAL:
status = dc_serial_iterator_new (&iterator, context, descriptor);
break;
case DC_TRANSPORT_IRDA:
status = dc_irda_iterator_new (&iterator, context, descriptor);
break;
case DC_TRANSPORT_BLUETOOTH:
status = dc_bluetooth_iterator_new (&iterator, context, descriptor);
break;
case DC_TRANSPORT_USB:
status = dc_usb_iterator_new (&iterator, context, descriptor);
break;
case DC_TRANSPORT_USBHID:
status = dc_usbhid_iterator_new (&iterator, context, descriptor);
break;
default:
status = DC_STATUS_UNSUPPORTED;
break;
}
if (status != DC_STATUS_SUCCESS) {
ERROR ("Failed to create the device iterator.");
goto cleanup;
}
// Enumerate the devices.
void *device = NULL;
while ((status = dc_iterator_next (iterator, &device)) == DC_STATUS_SUCCESS) {
char buffer[DC_BLUETOOTH_SIZE];
switch (transport) {
case DC_TRANSPORT_SERIAL:
printf ("%s\n", dc_serial_device_get_name (device));
dc_serial_device_free (device);
break;
case DC_TRANSPORT_IRDA:
printf ("%08x\t%s\n", dc_irda_device_get_address (device), dc_irda_device_get_name (device));
dc_irda_device_free (device);
break;
case DC_TRANSPORT_BLUETOOTH:
printf ("%s\t%s\n",
dc_bluetooth_addr2str(dc_bluetooth_device_get_address (device), buffer, sizeof(buffer)),
dc_bluetooth_device_get_name (device));
dc_bluetooth_device_free (device);
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:
printf ("%04x:%04x\n", dc_usbhid_device_get_vid (device), dc_usbhid_device_get_pid (device));
dc_usbhid_device_free (device);
break;
default:
break;
}
}
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_DONE) {
ERROR ("Failed to enumerate the devices.");
goto cleanup;
}
status = DC_STATUS_SUCCESS;
cleanup:
dc_iterator_free (iterator);
return status;
}
static int
dctool_scan_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
{
int exitcode = EXIT_SUCCESS;
dc_status_t status = DC_STATUS_SUCCESS;
// Default option values.
unsigned int help = 0;
dc_transport_t transport = dctool_transport_default (descriptor);
// Parse the command-line options.
int opt = 0;
const char *optstring = "ht:";
#ifdef HAVE_GETOPT_LONG
struct option options[] = {
{"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{0, 0, 0, 0 }
};
while ((opt = getopt_long (argc, argv, optstring, options, NULL)) != -1) {
#else
while ((opt = getopt (argc, argv, optstring)) != -1) {
#endif
switch (opt) {
case 'h':
help = 1;
break;
case 't':
transport = dctool_transport_type (optarg);
break;
default:
return EXIT_FAILURE;
}
}
argc -= optind;
argv += optind;
// Show help message.
if (help) {
dctool_command_showhelp (&dctool_scan);
return EXIT_SUCCESS;
}
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Scan for supported devices.
status = scan (context, descriptor, transport);
if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE;
goto cleanup;
}
cleanup:
return exitcode;
}
const dctool_command_t dctool_scan = {
dctool_scan_run,
DCTOOL_CONFIG_NONE,
"scan",
"Scan for supported devices",
"Usage:\n"
" dctool scan [options]\n"
"\n"
"Options:\n"
#ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
#else
" -h Show help message\n"
" -t <transport> Transport type\n"
#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
@ -41,27 +39,17 @@
#include "utils.h" #include "utils.h"
static dc_status_t static dc_status_t
do_timesync (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const dc_datetime_t *datetime) do_timesync (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, const dc_datetime_t *datetime)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -94,7 +82,6 @@ do_timesync (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t
cleanup: cleanup:
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -103,18 +90,16 @@ dctool_timesync_run (int argc, char *argv[], dc_context_t *context, dc_descripto
{ {
int exitcode = EXIT_SUCCESS; int exitcode = EXIT_SUCCESS;
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:"; const char *optstring = "h";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
while ((opt = getopt_long (argc, argv, optstring, options, NULL)) != -1) { while ((opt = getopt_long (argc, argv, optstring, options, NULL)) != -1) {
@ -125,9 +110,6 @@ dctool_timesync_run (int argc, char *argv[], dc_context_t *context, dc_descripto
case 'h': case 'h':
help = 1; help = 1;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
default: default:
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -142,13 +124,6 @@ dctool_timesync_run (int argc, char *argv[], dc_context_t *context, dc_descripto
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Get the system time. // Get the system time.
dc_datetime_t datetime = {0}; dc_datetime_t datetime = {0};
dc_ticks_t now = dc_datetime_now (); dc_ticks_t now = dc_datetime_now ();
@ -159,7 +134,7 @@ dctool_timesync_run (int argc, char *argv[], dc_context_t *context, dc_descripto
} }
// Synchronize the device clock. // Synchronize the device clock.
status = do_timesync (context, descriptor, transport, argv[0], &datetime); status = do_timesync (context, descriptor, argv[0], &datetime);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -180,10 +155,8 @@ const dctool_command_t dctool_timesync = {
"\n" "\n"
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
#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
@ -41,27 +39,17 @@
#include "utils.h" #include "utils.h"
static dc_status_t static dc_status_t
dowrite (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, unsigned int address, dc_buffer_t *buffer) dowrite (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, unsigned int address, dc_buffer_t *buffer)
{ {
dc_status_t rc = DC_STATUS_SUCCESS; dc_status_t rc = DC_STATUS_SUCCESS;
dc_iostream_t *iostream = NULL;
dc_device_t *device = NULL; dc_device_t *device = NULL;
// Open the I/O stream.
message ("Opening the I/O stream (%s, %s).\n",
dctool_transport_name (transport),
devname ? devname : "null");
rc = dctool_iostream_open (&iostream, context, descriptor, transport, devname);
if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the I/O stream.");
goto cleanup;
}
// Open the device. // Open the device.
message ("Opening the device (%s %s).\n", message ("Opening the device (%s %s, %s).\n",
dc_descriptor_get_vendor (descriptor), dc_descriptor_get_vendor (descriptor),
dc_descriptor_get_product (descriptor)); dc_descriptor_get_product (descriptor),
rc = dc_device_open (&device, context, descriptor, iostream); devname ? devname : "null");
rc = dc_device_open (&device, context, descriptor, devname);
if (rc != DC_STATUS_SUCCESS) { if (rc != DC_STATUS_SUCCESS) {
ERROR ("Error opening the device."); ERROR ("Error opening the device.");
goto cleanup; goto cleanup;
@ -94,7 +82,6 @@ dowrite (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t tran
cleanup: cleanup:
dc_device_close (device); dc_device_close (device);
dc_iostream_close (iostream);
return rc; return rc;
} }
@ -104,7 +91,6 @@ dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
int exitcode = EXIT_SUCCESS; int exitcode = EXIT_SUCCESS;
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
dc_buffer_t *buffer = NULL; dc_buffer_t *buffer = NULL;
dc_transport_t transport = dctool_transport_default (descriptor);
// Default option values. // Default option values.
unsigned int help = 0; unsigned int help = 0;
@ -114,11 +100,10 @@ dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
// Parse the command-line options. // Parse the command-line options.
int opt = 0; int opt = 0;
const char *optstring = "ht:a:c:i:"; const char *optstring = "ha:c:i:";
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
struct option options[] = { struct option options[] = {
{"help", no_argument, 0, 'h'}, {"help", no_argument, 0, 'h'},
{"transport", required_argument, 0, 't'},
{"address", required_argument, 0, 'a'}, {"address", required_argument, 0, 'a'},
{"count", required_argument, 0, 'c'}, {"count", required_argument, 0, 'c'},
{"input", required_argument, 0, 'i'}, {"input", required_argument, 0, 'i'},
@ -132,9 +117,6 @@ dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
case 'h': case 'h':
help = 1; help = 1;
break; break;
case 't':
transport = dctool_transport_type (optarg);
break;
case 'a': case 'a':
address = strtoul (optarg, NULL, 0); address = strtoul (optarg, NULL, 0);
have_address = 1; have_address = 1;
@ -160,13 +142,6 @@ dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
// Check the transport type.
if (transport == DC_TRANSPORT_NONE) {
message ("No valid transport type specified.\n");
exitcode = EXIT_FAILURE;
goto cleanup;
}
// Check mandatory arguments. // Check mandatory arguments.
if (!have_address) { if (!have_address) {
message ("No memory address specified.\n"); message ("No memory address specified.\n");
@ -190,7 +165,7 @@ dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t
} }
// Write data to the internal memory. // Write data to the internal memory.
status = dowrite (context, descriptor, transport, argv[0], address, buffer); status = dowrite (context, descriptor, argv[0], address, buffer);
if (status != DC_STATUS_SUCCESS) { if (status != DC_STATUS_SUCCESS) {
message ("ERROR: %s\n", dctool_errmsg (status)); message ("ERROR: %s\n", dctool_errmsg (status));
exitcode = EXIT_FAILURE; exitcode = EXIT_FAILURE;
@ -213,13 +188,11 @@ const dctool_command_t dctool_write = {
"Options:\n" "Options:\n"
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
" -h, --help Show help message\n" " -h, --help Show help message\n"
" -t, --transport <name> Transport type\n"
" -a, --address <address> Memory address\n" " -a, --address <address> Memory address\n"
" -c, --count <count> Number of bytes\n" " -c, --count <count> Number of bytes\n"
" -i, --input <filename> Input filename\n" " -i, --input <filename> Input filename\n"
#else #else
" -h Show help message\n" " -h Show help message\n"
" -t <transport> Transport type\n"
" -a <address> Memory address\n" " -a <address> Memory address\n"
" -c <count> Number of bytes\n" " -c <count> Number of bytes\n"
" -i <filename> Input filename\n" " -i <filename> Input filename\n"

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.
@ -281,20 +265,6 @@ dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const u
fprintf (output->ostream, "<maxdepth>%.2f</maxdepth>\n", fprintf (output->ostream, "<maxdepth>%.2f</maxdepth>\n",
convert_depth(maxdepth, output->units)); convert_depth(maxdepth, output->units));
// Parse the avgdepth.
message ("Parsing the avgdepth.\n");
double avgdepth = 0.0;
status = dc_parser_get_field (parser, DC_FIELD_AVGDEPTH, 0, &avgdepth);
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
ERROR ("Error parsing the avgdepth.");
goto cleanup;
}
if (status != DC_STATUS_UNSUPPORTED) {
fprintf (output->ostream, "<avgdepth>%.2f</avgdepth>\n",
convert_depth(avgdepth, output->units));
}
// Parse the temperature. // Parse the temperature.
message ("Parsing the temperature.\n"); message ("Parsing the temperature.\n");
for (unsigned int i = 0; i < 3; ++i) { for (unsigned int i = 0; i < 3; ++i) {
@ -338,19 +308,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 +340,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 +372,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 +382,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

@ -3,18 +3,11 @@ libdivecomputer_HEADERS = \
version.h \ version.h \
common.h \ common.h \
context.h \ context.h \
custom_io.h \
buffer.h \ buffer.h \
descriptor.h \ descriptor.h \
iterator.h \ iterator.h \
iostream.h \ iostream.h \
ioctl.h \
serial.h \
bluetooth.h \
ble.h \
irda.h \
usb.h \
usbhid.h \
custom.h \
device.h \ device.h \
parser.h \ parser.h \
datetime.h \ datetime.h \
@ -31,5 +24,4 @@ libdivecomputer_HEADERS = \
hw_ostc.h \ hw_ostc.h \
hw_frog.h \ hw_frog.h \
hw_ostc3.h \ hw_ostc3.h \
atomics_cobalt.h \ atomics_cobalt.h
divesystem_idive.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

@ -1,54 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2019 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_BLE_H
#define DC_BLE_H
#include "ioctl.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Get the remote device name.
*/
#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
}
#endif /* __cplusplus */
#endif /* DC_BLE_H */

View File

@ -1,135 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2013 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_BLUETOOTH_H
#define DC_BLUETOOTH_H
#include "common.h"
#include "context.h"
#include "iostream.h"
#include "iterator.h"
#include "descriptor.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* The minimum number of bytes (including the terminating null byte) for
* formatting a bluetooth address as a string.
*/
#define DC_BLUETOOTH_SIZE 18
/**
* Bluetooth address (48 bits).
*/
#if defined (_WIN32) && !defined (__GNUC__)
typedef unsigned __int64 dc_bluetooth_address_t;
#else
typedef unsigned long long dc_bluetooth_address_t;
#endif
/**
* Convert a bluetooth address to a string.
*
* 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 #DC_BLUETOOTH_SIZE bytes.
*
* @param[in] address A bluetooth address.
* @param[in] str The memory buffer to store the result.
* @param[in] size The size of the memory buffer.
* @returns The null-terminated string on success, or NULL on failure.
*/
char *
dc_bluetooth_addr2str(dc_bluetooth_address_t address, char *str, size_t size);
/**
* Convert a string to a bluetooth address.
*
* The string 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.
*
* @param[in] address A null-terminated string.
* @returns The bluetooth address on success, or zero on failure.
*/
dc_bluetooth_address_t
dc_bluetooth_str2addr(const char *address);
/**
* Opaque object representing a bluetooth device.
*/
typedef struct dc_bluetooth_device_t dc_bluetooth_device_t;
/**
* Get the address of the bluetooth device.
*
* @param[in] device A valid bluetooth device.
*/
dc_bluetooth_address_t
dc_bluetooth_device_get_address (dc_bluetooth_device_t *device);
/**
* Get the name of the bluetooth device.
*
* @param[in] device A valid bluetooth device.
*/
const char *
dc_bluetooth_device_get_name (dc_bluetooth_device_t *device);
/**
* Destroy the bluetooth device and free all resources.
*
* @param[in] device A valid bluetooth device.
*/
void
dc_bluetooth_device_free (dc_bluetooth_device_t *device);
/**
* Create an iterator to enumerate the bluetooth 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_bluetooth_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open an bluetooth connection.
*
* @param[out] iostream A location to store the bluetooth connection.
* @param[in] context A valid context object.
* @param[in] address The bluetooth device address.
* @param[in] port The bluetooth port number.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_bluetooth_open (dc_iostream_t **iostream, dc_context_t *context, dc_bluetooth_address_t address, unsigned int port);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_BLUETOOTH_H */

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

@ -41,20 +41,6 @@ typedef enum dc_status_t {
DC_STATUS_CANCELLED = -10 DC_STATUS_CANCELLED = -10
} dc_status_t; } dc_status_t;
typedef enum dc_transport_t {
DC_TRANSPORT_NONE = 0,
DC_TRANSPORT_SERIAL = (1 << 0),
DC_TRANSPORT_USB = (1 << 1),
DC_TRANSPORT_USBHID = (1 << 2),
DC_TRANSPORT_IRDA = (1 << 3),
DC_TRANSPORT_BLUETOOTH = (1 << 4),
DC_TRANSPORT_BLE = (1 << 5),
DC_TRANSPORT_USBSTORAGE= (1 << 6),
} dc_transport_t;
// Idiotic enums can't be queried
#define DC_TRANSPORT_USBSTORAGE DC_TRANSPORT_USBSTORAGE
typedef enum dc_family_t { typedef enum dc_family_t {
DC_FAMILY_NULL = 0, DC_FAMILY_NULL = 0,
/* Suunto */ /* Suunto */
@ -72,13 +58,12 @@ typedef enum dc_family_t {
DC_FAMILY_UWATEC_ALADIN = (3 << 16), DC_FAMILY_UWATEC_ALADIN = (3 << 16),
DC_FAMILY_UWATEC_MEMOMOUSE, DC_FAMILY_UWATEC_MEMOMOUSE,
DC_FAMILY_UWATEC_SMART, DC_FAMILY_UWATEC_SMART,
DC_FAMILY_UWATEC_MERIDIAN, /* Deprecated: integrated into the Uwatec Smart family. */ DC_FAMILY_UWATEC_MERIDIAN,
DC_FAMILY_UWATEC_G2, /* Deprecated: integrated into the Uwatec Smart family. */ DC_FAMILY_UWATEC_G2,
/* Oceanic */ /* Oceanic */
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,
@ -91,7 +76,6 @@ typedef enum dc_family_t {
/* Cressi */ /* Cressi */
DC_FAMILY_CRESSI_EDY = (7 << 16), DC_FAMILY_CRESSI_EDY = (7 << 16),
DC_FAMILY_CRESSI_LEONARDO, DC_FAMILY_CRESSI_LEONARDO,
DC_FAMILY_CRESSI_GOA,
/* Zeagle */ /* Zeagle */
DC_FAMILY_ZEAGLE_N2ITION3 = (8 << 16), DC_FAMILY_ZEAGLE_N2ITION3 = (8 << 16),
/* Atomic Aquatics */ /* Atomic Aquatics */
@ -107,28 +91,6 @@ typedef enum dc_family_t {
DC_FAMILY_DIVESYSTEM_IDIVE = (13 << 16), DC_FAMILY_DIVESYSTEM_IDIVE = (13 << 16),
/* Cochran */ /* Cochran */
DC_FAMILY_COCHRAN_COMMANDER = (14 << 16), DC_FAMILY_COCHRAN_COMMANDER = (14 << 16),
/* Tecdiving */
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 */
DC_FAMILY_GARMIN = (100 << 16),
} dc_family_t; } dc_family_t;
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -23,6 +23,7 @@
#define DC_CONTEXT_H #define DC_CONTEXT_H
#include "common.h" #include "common.h"
#include "custom_io.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -30,6 +31,9 @@ extern "C" {
typedef struct dc_context_t dc_context_t; typedef struct dc_context_t dc_context_t;
/* Opaque libdivecomputer *user* data structure */
typedef struct dc_user_device_t dc_user_device_t;
typedef enum dc_loglevel_t { typedef enum dc_loglevel_t {
DC_LOGLEVEL_NONE, DC_LOGLEVEL_NONE,
DC_LOGLEVEL_ERROR, DC_LOGLEVEL_ERROR,
@ -47,15 +51,15 @@ dc_context_new (dc_context_t **context);
dc_status_t dc_status_t
dc_context_free (dc_context_t *context); dc_context_free (dc_context_t *context);
dc_status_t
dc_context_set_custom_io (dc_context_t *context, dc_custom_io_t *custom_io, dc_user_device_t *);
dc_status_t dc_status_t
dc_context_set_loglevel (dc_context_t *context, dc_loglevel_t loglevel); dc_context_set_loglevel (dc_context_t *context, dc_loglevel_t loglevel);
dc_status_t dc_status_t
dc_context_set_logfunc (dc_context_t *context, dc_logfunc_t logfunc, void *userdata); dc_context_set_logfunc (dc_context_t *context, dc_logfunc_t logfunc, void *userdata);
unsigned int
dc_context_get_transports (dc_context_t *context);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -0,0 +1,71 @@
#ifndef CUSTOM_IO_H
#define CUSTOM_IO_H
#include <libdivecomputer/iostream.h>
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
struct dc_context_t;
struct dc_user_device_t;
/*
* Two different pointers to user-supplied data.
*
* The 'userdata' pointer is for the IO routines themselves,
* generally filled in by the 'xyz_open()' routine with whatever
* file descriptor etc information.
*
* The 'user_device' pointer is set when registering the
* custom IO with the download context, and has whatever
* data the downloader needs.
*
* The two are very different. The userdata is "per instance",
* and when nesting custom IO handlers, each level would
* generally have its own userdata, that would be specific
* to that particular set of IO routines.
*
* In contrast, the user_device is filled in when the
* download context is created, before open() is even called,
* and isn't specific to the IO routines, but to the download
* as a whole.
*/
typedef struct dc_custom_io_t
{
void *userdata;
struct dc_user_device_t *user_device;
// Custom serial (generally BT rfcomm)
dc_status_t (*serial_open) (struct dc_custom_io_t *io, struct dc_context_t *, const char *name);
dc_status_t (*serial_close) (struct dc_custom_io_t *io);
dc_status_t (*serial_read) (struct dc_custom_io_t *io, void* data, size_t size, size_t *actual);
dc_status_t (*serial_write) (struct dc_custom_io_t *io, const void* data, size_t size, size_t *actual);
dc_status_t (*serial_purge) (struct dc_custom_io_t *io, dc_direction_t);
dc_status_t (*serial_get_available) (struct dc_custom_io_t *io, size_t *value);
dc_status_t (*serial_set_timeout) (struct dc_custom_io_t *io, long timeout);
dc_status_t (*serial_configure) (struct dc_custom_io_t *io, unsigned int baudrate, unsigned int databits, dc_parity_t parity, dc_stopbits_t stopbits, dc_flowcontrol_t flowcontrol);
dc_status_t (*serial_set_dtr) (struct dc_custom_io_t *io, int level);
dc_status_t (*serial_set_rts) (struct dc_custom_io_t *io, int level);
dc_status_t (*serial_set_halfduplex) (struct dc_custom_io_t *io, unsigned int value);
dc_status_t (*serial_set_break) (struct dc_custom_io_t *io, unsigned int level);
//dc_serial_set_latency (dc_serial_t *device, unsigned int milliseconds) - Unused
//dc_serial_get_lines (dc_serial_t *device, unsigned int *value) - Unused
//dc_serial_flush (dc_serial_t *device) - No device interaction
//dc_serial_sleep (dc_serial_t *device, unsigned int timeout) - No device interaction
// Custom packet transfer (generally BLE GATT)
int packet_size;
dc_status_t (*packet_open) (struct dc_custom_io_t *, struct dc_context_t *, const char *);
dc_status_t (*packet_close) (struct dc_custom_io_t *);
dc_status_t (*packet_read) (struct dc_custom_io_t *, void* data, size_t size, size_t *actual);
dc_status_t (*packet_write) (struct dc_custom_io_t *, const void* data, size_t size, size_t *actual);
} dc_custom_io_t;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* CUSTOM_IO_H */

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,95 +29,40 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/** typedef enum dc_transport_t {
* Opaque object representing a supported dive computer. DC_TRANSPORT_NONE,
*/ DC_TRANSPORT_SERIAL,
DC_TRANSPORT_USB,
DC_TRANSPORT_USBHID,
DC_TRANSPORT_IRDA,
DC_TRANSPORT_BLUETOOTH
} dc_transport_t;
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_serial (dc_descriptor_t *descriptor);
/** dc_transport_t
* Check if a low-level I/O device matches a supported dive computer. dc_descriptor_get_transport (dc_descriptor_t *descriptor);
*
* @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
} }

View File

@ -25,7 +25,6 @@
#include "common.h" #include "common.h"
#include "context.h" #include "context.h"
#include "descriptor.h" #include "descriptor.h"
#include "iostream.h"
#include "buffer.h" #include "buffer.h"
#include "datetime.h" #include "datetime.h"
@ -71,7 +70,7 @@ typedef void (*dc_event_callback_t) (dc_device_t *device, dc_event_type_t event,
typedef int (*dc_dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata); typedef int (*dc_dive_callback_t) (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata);
dc_status_t dc_status_t
dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, dc_iostream_t *iostream); dc_device_open (dc_device_t **out, dc_context_t *context, dc_descriptor_t *descriptor, const char *name);
dc_family_t dc_family_t
dc_device_get_type (dc_device_t *device); dc_device_get_type (dc_device_t *device);

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

@ -1,73 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2019 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_IOCTL_H
#define DC_IOCTL_H
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*
* Ioctl direction bits.
*
* Note: WRITE means the application is writing and the driver is
* reading. READ means the application is reading and the driver is
* writing.
*/
#define DC_IOCTL_DIR_NONE 0u
#define DC_IOCTL_DIR_READ 1u
#define DC_IOCTL_DIR_WRITE 2u
/*
* Ioctl variable size bits.
*/
#define DC_IOCTL_SIZE_VARIABLE 0
/*
* Helper macro to encode ioctl numbers.
*/
#define DC_IOCTL_BASE(dir,type,nr,size) \
(((dir) << 30) | \
((size) << 16) | \
((type) << 8) | \
((nr) << 0))
/*
* Macros to encode ioctl numbers.
*/
#define DC_IOCTL_IO(type,nr) DC_IOCTL_BASE(DC_IOCTL_DIR_NONE, (type), (nr), 0)
#define DC_IOCTL_IOR(type,nr,size) DC_IOCTL_BASE(DC_IOCTL_DIR_READ, (type), (nr), (size))
#define DC_IOCTL_IOW(type,nr,size) DC_IOCTL_BASE(DC_IOCTL_DIR_WRITE, (type), (nr), (size))
#define DC_IOCTL_IORW(type,nr,size) DC_IOCTL_BASE(DC_IOCTL_DIR_READ | DC_IOCTL_DIR_WRITE, (type), (nr), (size))
/*
* Macros to decode ioctl numbers.
*/
#define DC_IOCTL_DIR(request) (((request) >> 30) & 0x0003)
#define DC_IOCTL_SIZE(request) (((request) >> 16) & 0x3FFF)
#define DC_IOCTL_TYPE(request) (((request) >> 8) & 0x00FF)
#define DC_IOCTL_NR(request) (((request) >> 0) & 0x00FF)
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_IOCTL_H */

View File

@ -22,7 +22,6 @@
#ifndef DC_IOSTREAM_H #ifndef DC_IOSTREAM_H
#define DC_IOSTREAM_H #define DC_IOSTREAM_H
#include <stddef.h>
#include <libdivecomputer/common.h> #include <libdivecomputer/common.h>
#include <libdivecomputer/context.h> #include <libdivecomputer/context.h>
@ -83,15 +82,6 @@ typedef enum dc_line_t {
DC_LINE_RNG = 0x08, /**< Ring indicator */ DC_LINE_RNG = 0x08, /**< Ring indicator */
} dc_line_t; } dc_line_t;
/**
* Get the transport type.
*
* @param[in] iostream A valid I/O stream.
* @returns The transport type of the I/O stream.
*/
dc_transport_t
dc_iostream_get_transport (dc_iostream_t *iostream);
/** /**
* Set the read timeout. * Set the read timeout.
* *
@ -123,6 +113,33 @@ dc_iostream_get_transport (dc_iostream_t *iostream);
dc_status_t dc_status_t
dc_iostream_set_timeout (dc_iostream_t *iostream, int timeout); dc_iostream_set_timeout (dc_iostream_t *iostream, int timeout);
/**
* Set the receive latency.
*
* The effect of this setting is highly platform and driver specific. On
* Windows it does nothing at all, on Linux it controls the low latency
* flag (e.g. only zero vs non-zero latency), and on Mac OS X it sets
* the receive latency as requested.
*
* @param[in] iostream A valid I/O stream.
* @param[in] value The latency in milliseconds.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_iostream_set_latency (dc_iostream_t *iostream, unsigned int value);
/**
* Set the state of the half duplex emulation.
*
* @param[in] iostream A valid I/O stream.
* @param[in] value The half duplex state.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_iostream_set_halfduplex (dc_iostream_t *iostream, unsigned int value);
/** /**
* Set the state of the break condition. * Set the state of the break condition.
* *
@ -195,36 +212,6 @@ dc_iostream_get_available (dc_iostream_t *iostream, size_t *value);
dc_status_t dc_status_t
dc_iostream_configure (dc_iostream_t *iostream, unsigned int baudrate, unsigned int databits, dc_parity_t parity, dc_stopbits_t stopbits, dc_flowcontrol_t flowcontrol); dc_iostream_configure (dc_iostream_t *iostream, unsigned int baudrate, unsigned int databits, dc_parity_t parity, dc_stopbits_t stopbits, dc_flowcontrol_t flowcontrol);
/**
* Poll the I/O stream for available data.
*
* There are three distinct modes available:
*
* 1. Blocking (timeout < 0):
*
* The poll operation is blocked until one or more bytes have been
* received. If no bytes are received, the operation will block
* forever.
*
* 2. Non-blocking (timeout == 0):
*
* The poll operation returns immediately, even if no bytes have
* been received.
*
* 3. Timeout (timeout > 0):
*
* The poll operation is blocked until one or more bytes have been
* received. If no bytes are received within the specified amount of
* time, the operation will return with a timeout.
*
* @param[in] iostream A valid I/O stream.
* @param[in] timeout The timeout in milliseconds.
* @returns #DC_STATUS_SUCCESS on success, #DC_STATUS_TIMEOUT on
* timeout, or another #dc_status_t code on failure.
*/
dc_status_t
dc_iostream_poll (dc_iostream_t *iostream, int timeout);
/** /**
* Read data from the I/O stream. * Read data from the I/O stream.
* *
@ -253,19 +240,6 @@ dc_iostream_read (dc_iostream_t *iostream, void *data, size_t size, size_t *actu
dc_status_t dc_status_t
dc_iostream_write (dc_iostream_t *iostream, const void *data, size_t size, size_t *actual); dc_iostream_write (dc_iostream_t *iostream, const void *data, size_t size, size_t *actual);
/**
* Perform an I/O stream specific request.
*
* @param[in] iostream A valid I/O stream.
* @param[in] request The request to perform.
* @param[in,out] data The request specific data.
* @param[in] size The size of the request specific data.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_iostream_ioctl (dc_iostream_t *iostream, unsigned int request, void *data, size_t size);
/** /**
* Flush the internal output buffer and wait until the data has been * Flush the internal output buffer and wait until the data has been
* transmitted. * transmitted.
@ -310,9 +284,6 @@ dc_iostream_sleep (dc_iostream_t *iostream, unsigned int milliseconds);
dc_status_t dc_status_t
dc_iostream_close (dc_iostream_t *iostream); dc_iostream_close (dc_iostream_t *iostream);
dc_status_t
dc_usb_storage_open (dc_iostream_t **out, dc_context_t *context, const char *name);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -1,92 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2008 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_IRDA_H
#define DC_IRDA_H
#include "common.h"
#include "context.h"
#include "iostream.h"
#include "iterator.h"
#include "descriptor.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* Opaque object representing an IrDA device.
*/
typedef struct dc_irda_device_t dc_irda_device_t;
/**
* Get the address of the IrDA device.
*
* @param[in] device A valid IrDA device.
*/
unsigned int
dc_irda_device_get_address (dc_irda_device_t *device);
/**
* Get the name of the IrDA device.
*
* @param[in] device A valid IrDA device.
*/
const char *
dc_irda_device_get_name (dc_irda_device_t *device);
/**
* Destroy the IrDA device and free all resources.
*
* @param[in] device A valid IrDA device.
*/
void
dc_irda_device_free (dc_irda_device_t *device);
/**
* Create an iterator to enumerate the IrDA 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_irda_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open an IrDA connection.
*
* @param[out] iostream A location to store the IrDA connection.
* @param[in] context A valid context object.
* @param[in] address The IrDA device address.
* @param[in] lsap The IrDA LSAP number.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_irda_open (dc_iostream_t **iostream, dc_context_t *context, unsigned int address, unsigned int lsap);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_IRDA_H */

View File

@ -46,13 +46,9 @@ typedef enum dc_sample_type_t {
DC_SAMPLE_PPO2, DC_SAMPLE_PPO2,
DC_SAMPLE_CNS, DC_SAMPLE_CNS,
DC_SAMPLE_DECO, DC_SAMPLE_DECO,
DC_SAMPLE_GASMIX, DC_SAMPLE_GASMIX
DC_SAMPLE_TTS, // time to surface in seconds
} dc_sample_type_t; } dc_sample_type_t;
// Make it easy to test support compile-time with "#ifdef DC_SAMPLE_TTS"
#define DC_SAMPLE_TTS DC_SAMPLE_TTS
typedef enum dc_field_type_t { typedef enum dc_field_type_t {
DC_FIELD_DIVETIME, DC_FIELD_DIVETIME,
DC_FIELD_MAXDEPTH, DC_FIELD_MAXDEPTH,
@ -67,7 +63,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;
@ -119,30 +114,13 @@ typedef enum parser_sample_flags_t {
#define SAMPLE_FLAGS_SEVERITY_SHIFT 2 #define SAMPLE_FLAGS_SEVERITY_SHIFT 2
#define SAMPLE_FLAGS_SEVERITY_MISSING (0 << SAMPLE_FLAGS_SEVERITY_SHIFT)
#define SAMPLE_FLAGS_SEVERITY_STATE (1 << SAMPLE_FLAGS_SEVERITY_SHIFT)
#define SAMPLE_FLAGS_SEVERITY_INFO (2 << SAMPLE_FLAGS_SEVERITY_SHIFT)
#define SAMPLE_FLAGS_SEVERITY_WARN (3 << SAMPLE_FLAGS_SEVERITY_SHIFT)
#define SAMPLE_FLAGS_SEVERITY_ALARM (4 << SAMPLE_FLAGS_SEVERITY_SHIFT)
/* these are used for the types of TAGs in Shearwater PNF info events */
#define SAMPLE_FLAGS_TYPE_SHIFT 5
#define SAMPLE_FLAGS_TYPE_MASK (7 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_NONE (0 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_INTEREST (1 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_NAVPOINT (2 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_DANGER (3 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_ANIMAL (4 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_ISSUE (5 << SAMPLE_FLAGS_TYPE_SHIFT)
#define SAMPLE_FLAGS_TYPE_INJURY (6 << SAMPLE_FLAGS_TYPE_SHIFT)
typedef enum parser_sample_vendor_t { typedef enum parser_sample_vendor_t {
SAMPLE_VENDOR_NONE, SAMPLE_VENDOR_NONE,
SAMPLE_VENDOR_UWATEC_ALADIN, SAMPLE_VENDOR_UWATEC_ALADIN,
SAMPLE_VENDOR_UWATEC_SMART, SAMPLE_VENDOR_UWATEC_SMART,
SAMPLE_VENDOR_OCEANIC_VTPRO, SAMPLE_VENDOR_OCEANIC_VTPRO,
SAMPLE_VENDOR_OCEANIC_VEO250, SAMPLE_VENDOR_OCEANIC_VEO250,
SAMPLE_VENDOR_OCEANIC_ATOM2 SAMPLE_VENDOR_OCEANIC_ATOM2,
} parser_sample_vendor_t; } parser_sample_vendor_t;
typedef enum dc_water_t { typedef enum dc_water_t {
@ -173,32 +151,26 @@ 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
#define DC_TANKVOLUME_METRIC DC_TANKINFO_METRIC #define DC_TANKVOLUME_METRIC DC_TANKINFO_METRIC
#define DC_TANKVOLUME_IMPERIAL DC_TANKINFO_IMPERIAL #define DC_TANKVOLUME_IMPERIAL DC_TANKINFO_IMPERIAL
/* /*
* Tank volume * Tank volume
* *
@ -222,11 +194,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 +201,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;
@ -290,9 +219,9 @@ typedef union dc_sample_value_t {
struct { struct {
unsigned int type; unsigned int type;
unsigned int time; unsigned int time;
const char *name;
unsigned int flags; unsigned int flags;
unsigned int value; unsigned int value;
const char *name;
} event; } event;
unsigned int rbt; unsigned int rbt;
unsigned int heartbeat; unsigned int heartbeat;
@ -303,41 +232,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,94 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2008 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_SERIAL_H
#define DC_SERIAL_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 */
/**
* Opaque object representing a serial device.
*/
typedef struct dc_serial_device_t dc_serial_device_t;
/**
* Get the device node of the serial device.
*
* @param[in] device A valid serial device.
*/
const char *
dc_serial_device_get_name (dc_serial_device_t *device);
/**
* Destroy the serial device and free all resources.
*
* @param[in] device A valid serial device.
*/
void
dc_serial_device_free (dc_serial_device_t *device);
/**
* Create an iterator to enumerate the serial 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_serial_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open a serial connection.
*
* @param[out] iostream A location to store the serial connection.
* @param[in] context A valid context object.
* @param[in] name The name of the device node.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_serial_open (dc_iostream_t **iostream, dc_context_t *context, const char *name);
/**
* Set the receive latency in milliseconds.
*
* The effect of this setting is highly platform and driver specific. On
* Windows it does nothing at all, on Linux it controls the low latency
* flag (e.g. only zero vs non-zero latency), and on Mac OS X it sets
* the receive latency as requested.
*/
#define DC_IOCTL_SERIAL_SET_LATENCY DC_IOCTL_IOW('s', 0, sizeof(unsigned int))
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_SERIAL_H */

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

@ -1,99 +0,0 @@
/*
* libdivecomputer
*
* Copyright (C) 2016 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_USBHID_H
#define DC_USBHID_H
#include "common.h"
#include "context.h"
#include "iostream.h"
#include "iterator.h"
#include "descriptor.h"
#ifdef __cplusplus
extern "C" {
#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.
*/
typedef struct dc_usbhid_device_t dc_usbhid_device_t;
/**
* Get the vendor id (VID) of the USB HID device.
*
* @param[in] device A valid USB HID device.
*/
unsigned int
dc_usbhid_device_get_vid (dc_usbhid_device_t *device);
/**
* Get the product id (PID) of the USB HID device.
*
* @param[in] device A valid USB HID device.
*/
unsigned int
dc_usbhid_device_get_pid (dc_usbhid_device_t *device);
/**
* Destroy the USB HID device and free all resources.
*
* @param[in] device A valid USB HID device.
*/
void
dc_usbhid_device_free(dc_usbhid_device_t *device);
/**
* Create an iterator to enumerate the USB HID 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_usbhid_iterator_new (dc_iterator_t **iterator, dc_context_t *context, dc_descriptor_t *descriptor);
/**
* Open a USB HID connection.
*
* @param[out] iostream A location to store the USB HID connection.
* @param[in] context A valid context object.
* @param[in] device A valid USB HID device.
* @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code
* on failure.
*/
dc_status_t
dc_usbhid_open (dc_iostream_t **iostream, dc_context_t *context, dc_usbhid_device_t *device);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* DC_USBHID_H */

View File

@ -26,6 +26,10 @@
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
/* use these defines to detect Subsurface specific features */
#define SSRF_LIBDC_VERSION 2
#define SSRF_CUSTOM_IO 2
#define DC_VERSION "@DC_VERSION@" #define DC_VERSION "@DC_VERSION@"
#define DC_VERSION_MAJOR @DC_VERSION_MAJOR@ #define DC_VERSION_MAJOR @DC_VERSION_MAJOR@
#define DC_VERSION_MINOR @DC_VERSION_MINOR@ #define DC_VERSION_MINOR @DC_VERSION_MINOR@

895
msvc/libdivecomputer.vcproj Normal file
View File

@ -0,0 +1,895 @@
<?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_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\usbhid.c"
>
</File>
<File
RelativePath="..\src\uwatec_aladin.c"
>
</File>
<File
RelativePath="..\src\uwatec_g2.c"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse.c"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse_parser.c"
>
</File>
<File
RelativePath="..\src\uwatec_meridian.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="..\src\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_leonardo.h"
>
</File>
<File
RelativePath="..\src\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="..\src\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="..\src\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="..\include\libdivecomputer\units.h"
>
</File>
<File
RelativePath="..\src\usbhid.h"
>
</File>
<File
RelativePath="..\src\uwatec_aladin.h"
>
</File>
<File
RelativePath="..\src\uwatec_g2.h"
>
</File>
<File
RelativePath="..\src\uwatec_memomouse.h"
>
</File>
<File
RelativePath="..\src\uwatec_meridian.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 -lz
libdivecomputer_la_LDFLAGS = \ libdivecomputer_la_LDFLAGS = \
-version-info $(DC_VERSION_LIBTOOL) \ -version-info $(DC_VERSION_LIBTOOL) \
-no-undefined \ -no-undefined \
@ -24,7 +24,6 @@ libdivecomputer_la_SOURCES = \
device-private.h device.c \ device-private.h device.c \
parser-private.h parser.c \ parser-private.h parser.c \
datetime.c \ datetime.c \
timer.h timer.c \
suunto_common.h suunto_common.c \ suunto_common.h suunto_common.c \
suunto_common2.h suunto_common2.c \ suunto_common2.h suunto_common2.c \
suunto_solution.h suunto_solution.c suunto_solution_parser.c \ suunto_solution.h suunto_solution.c suunto_solution_parser.c \
@ -33,17 +32,18 @@ libdivecomputer_la_SOURCES = \
suunto_vyper2.h suunto_vyper2.c \ suunto_vyper2.h suunto_vyper2.c \
suunto_d9.h suunto_d9.c suunto_d9_parser.c \ suunto_d9.h suunto_d9.c suunto_d9_parser.c \
suunto_eonsteel.h suunto_eonsteel.c suunto_eonsteel_parser.c \ suunto_eonsteel.h suunto_eonsteel.c suunto_eonsteel_parser.c \
scubapro_g2.h scubapro_g2.c \
reefnet_sensus.h reefnet_sensus.c reefnet_sensus_parser.c \ reefnet_sensus.h reefnet_sensus.c reefnet_sensus_parser.c \
reefnet_sensuspro.h reefnet_sensuspro.c reefnet_sensuspro_parser.c \ reefnet_sensuspro.h reefnet_sensuspro.c reefnet_sensuspro_parser.c \
reefnet_sensusultra.h reefnet_sensusultra.c reefnet_sensusultra_parser.c \ reefnet_sensusultra.h reefnet_sensusultra.c reefnet_sensusultra_parser.c \
uwatec_aladin.h uwatec_aladin.c \ uwatec_aladin.h uwatec_aladin.c \
uwatec_memomouse.h uwatec_memomouse.c uwatec_memomouse_parser.c \ uwatec_memomouse.h uwatec_memomouse.c uwatec_memomouse_parser.c \
uwatec_smart.h uwatec_smart.c uwatec_smart_parser.c \ uwatec_smart.h uwatec_smart.c uwatec_smart_parser.c \
uwatec_meridian.h uwatec_meridian.c \
oceanic_common.h oceanic_common.c \ oceanic_common.h oceanic_common.c \
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 \
@ -56,7 +56,6 @@ libdivecomputer_la_SOURCES = \
aes.h aes.c \ aes.h aes.c \
cressi_edy.h cressi_edy.c cressi_edy_parser.c \ cressi_edy.h cressi_edy.c cressi_edy_parser.c \
cressi_leonardo.h cressi_leonardo.c cressi_leonardo_parser.c \ cressi_leonardo.h cressi_leonardo.c cressi_leonardo_parser.c \
cressi_goa.h cressi_goa.c cressi_goa_parser.c \
zeagle_n2ition3.h zeagle_n2ition3.c \ zeagle_n2ition3.h zeagle_n2ition3.c \
atomics_cobalt.h atomics_cobalt.c atomics_cobalt_parser.c \ atomics_cobalt.h atomics_cobalt.c atomics_cobalt_parser.c \
shearwater_common.h shearwater_common.c \ shearwater_common.h shearwater_common.c \
@ -65,44 +64,27 @@ 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 \
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 \
mclean_extreme.h mclean_extreme.c mclean_extreme_parser.c \
liquivision_lynx.h liquivision_lynx.c liquivision_lynx_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 \
irda.c \
usb.c \
usbhid.c \
bluetooth.c \
custom.c
# Not merged upstream yet
libdivecomputer_la_SOURCES += \
usb_storage.c \
field-cache.h field-cache.c \
garmin.h garmin.c garmin_parser.c
if OS_WIN32 if OS_WIN32
libdivecomputer_la_SOURCES += serial_win32.c libdivecomputer_la_SOURCES += serial.h serial_win32.c
else else
libdivecomputer_la_SOURCES += serial_posix.c libdivecomputer_la_SOURCES += serial.h serial_posix.c
endif endif
libdivecomputer_la_SOURCES += socket.h socket.c
libdivecomputer_la_SOURCES += irda.h irda.c
libdivecomputer_la_SOURCES += usbhid.h usbhid.c
libdivecomputer_la_SOURCES += bluetooth.h bluetooth.c
libdivecomputer_la_SOURCES += custom.h custom.c
libdivecomputer_la_SOURCES += custom_io.c
if OS_WIN32 if OS_WIN32
libdivecomputer_la_SOURCES += libdivecomputer.rc libdivecomputer_la_SOURCES += libdivecomputer.rc
endif endif
@ -113,7 +95,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

@ -1,28 +1,4 @@
/* /*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
This is an implementation of the AES128 algorithm, specifically ECB and CBC mode. This is an implementation of the AES128 algorithm, specifically ECB and CBC mode.
@ -98,7 +74,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 +518,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 +560,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

@ -1,29 +1,3 @@
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
#ifndef _AES_H_ #ifndef _AES_H_
#define _AES_H_ #define _AES_H_

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)
{ {
@ -191,7 +167,7 @@ array_uint_be (const unsigned char data[], unsigned int n)
unsigned int value = 0; unsigned int value = 0;
for (unsigned int i = 0; i < n; ++i) { for (unsigned int i = 0; i < n; ++i) {
shift -= 8; shift -= 8;
value |= (unsigned int) data[i] << shift; value |= data[i] << shift;
} }
return value; return value;
} }
@ -202,170 +178,76 @@ array_uint_le (const unsigned char data[], unsigned int n)
unsigned int shift = 0; unsigned int shift = 0;
unsigned int value = 0; unsigned int value = 0;
for (unsigned int i = 0; i < n; ++i) { for (unsigned int i = 0; i < n; ++i) {
value |= (unsigned int) data[i] << shift; value |= data[i] << shift;
shift += 8; shift += 8;
} }
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[])
{ {
return ((unsigned int) data[0] << 24) | return (data[0] << 24) + (data[1] << 16) + (data[2] << 8) + data[3];
((unsigned int) data[1] << 16) |
((unsigned int) data[2] << 8) |
((unsigned int) data[3] << 0);
} }
unsigned int unsigned int
array_uint32_le (const unsigned char data[]) array_uint32_le (const unsigned char data[])
{ {
return ((unsigned int) data[0] << 0) | return data[0] + (data[1] << 8) + (data[2] << 16) + (data[3] << 24);
((unsigned int) data[1] << 8) |
((unsigned int) data[2] << 16) |
((unsigned int) data[3] << 24);
} }
unsigned int unsigned int
array_uint32_word_be (const unsigned char data[]) array_uint32_word_be (const unsigned char data[])
{ {
return ((unsigned int) data[0] << 8) | return data[1] + (data[0] << 8) + (data[3] << 16) + (data[2] << 24);
((unsigned int) data[1] << 0) |
((unsigned int) data[2] << 24) |
((unsigned int) data[3] << 16);
} }
unsigned int
array_uint24_be (const unsigned char data[])
{
return ((unsigned int) data[0] << 16) |
((unsigned int) data[1] << 8) |
((unsigned int) data[2] << 0);
}
unsigned int
array_uint24_le (const unsigned char data[])
{
return ((unsigned int) data[0] << 0) |
((unsigned int) data[1] << 8) |
((unsigned int) data[2] << 16);
}
unsigned short
array_uint16_be (const unsigned char data[])
{
return ((unsigned int) data[0] << 8) |
((unsigned int) data[1] << 0);
}
unsigned short
array_uint16_le (const unsigned char data[])
{
return ((unsigned int) data[0] << 0) |
((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 void
array_uint32_le_set (unsigned char data[], const unsigned int input) array_uint32_le_set (unsigned char data[], const unsigned int input)
{ {
data[0] = (input ) & 0xFF; data[0] = input & 0xFF;
data[1] = (input >> 8) & 0xFF; data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF; data[2] = (input >> 16) & 0xFF;
data[3] = (input >> 24) & 0xFF; data[3] = (input >> 24) & 0xFF;
} }
unsigned int
array_uint24_be (const unsigned char data[])
{
return (data[0] << 16) + (data[1] << 8) + data[2];
}
void void
array_uint24_be_set (unsigned char data[], const unsigned int input) array_uint24_be_set (unsigned char data[], const unsigned int input)
{ {
data[0] = (input >> 16) & 0xFF; data[0] = (input >> 16) & 0xFF;
data[1] = (input >> 8) & 0xFF; data[1] = (input >> 8) & 0xFF;
data[2] = (input ) & 0xFF; data[2] = input & 0xFF;
} }
void
array_uint24_le_set (unsigned char data[], const unsigned int input) unsigned int
array_uint24_le (const unsigned char data[])
{ {
data[0] = (input ) & 0xFF; return data[0] + (data[1] << 8) + (data[2] << 16);
data[1] = (input >> 8) & 0xFF;
data[2] = (input >> 16) & 0xFF;
} }
void unsigned short
array_uint16_be_set (unsigned char data[], const unsigned short input) array_uint16_be (const unsigned char data[])
{ {
data[0] = (input >> 8) & 0xFF; return (data[0] << 8) + data[1];
data[1] = (input ) & 0xFF;
} }
void
array_uint16_le_set (unsigned char data[], const unsigned short input) unsigned short
array_uint16_le (const unsigned char data[])
{ {
data[0] = (input ) & 0xFF; return data[0] + (data[1] << 8);
data[1] = (input >> 8) & 0xFF;
} }
unsigned char unsigned char
@ -373,45 +255,3 @@ 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-1.0/libusb.h>
#endif
#include "atomics_cobalt.h" #include "atomics_cobalt.h"
#include "context-private.h" #include "context-private.h"
@ -32,8 +41,7 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &atomics_cobalt_device_vtable) #define ISINSTANCE(device) dc_device_isinstance((device), &atomics_cobalt_device_vtable)
#define COBALT1 0 #define EXITCODE(rc) (rc == LIBUSB_ERROR_TIMEOUT ? DC_STATUS_TIMEOUT : DC_STATUS_IO)
#define COBALT2 2
#define VID 0x0471 #define VID 0x0471
#define PID 0x0888 #define PID 0x0888
@ -41,15 +49,15 @@
#define FP_OFFSET 20 #define FP_OFFSET 20
#define SZ_HEADER 228 #define SZ_MEMORY (29 * 64 * 1024)
#define SZ_MEMORY1 (29 * 64 * 1024) // Cobalt 1
#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 +65,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 +76,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 +100,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 +198,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 +206,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 +242,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 +263,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 +339,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
} }
@ -307,12 +350,9 @@ atomics_cobalt_device_foreach (dc_device_t *abstract, dc_dive_callback_t callbac
{ {
atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract; atomics_cobalt_device_t *device = (atomics_cobalt_device_t *) abstract;
// Get the model number.
unsigned int model = array_uint16_le (device->version + 12);
// Enable progress notifications. // Enable progress notifications.
dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER; dc_event_progress_t progress = EVENT_PROGRESS_INITIALIZER;
progress.maximum = (model == COBALT2 ? SZ_MEMORY2 : SZ_MEMORY1) + 2; progress.maximum = SZ_MEMORY + 2;
device_event_emit (abstract, DC_EVENT_PROGRESS, &progress); device_event_emit (abstract, DC_EVENT_PROGRESS, &progress);
// Emit a vendor event. // Emit a vendor event.
@ -349,12 +389,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 +399,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

@ -30,7 +30,6 @@
#ifdef _WIN32 #ifdef _WIN32
#ifdef HAVE_WS2BTH_H #ifdef HAVE_WS2BTH_H
#define BLUETOOTH #define BLUETOOTH
#include <initguid.h>
#include <ws2bth.h> #include <ws2bth.h>
#endif #endif
#else #else
@ -40,18 +39,14 @@
#include <bluetooth/rfcomm.h> #include <bluetooth/rfcomm.h>
#include <bluetooth/hci.h> #include <bluetooth/hci.h>
#include <bluetooth/hci_lib.h> #include <bluetooth/hci_lib.h>
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#endif #endif
#endif #endif
#include <libdivecomputer/bluetooth.h> #include "bluetooth.h"
#include "common-private.h" #include "common-private.h"
#include "context-private.h" #include "context-private.h"
#include "iostream-private.h" #include "iostream-private.h"
#include "iterator-private.h"
#include "platform.h"
#ifdef _WIN32 #ifdef _WIN32
#define DC_ADDRESS_FORMAT "%012I64X" #define DC_ADDRESS_FORMAT "%012I64X"
@ -66,49 +61,22 @@
#define ISINSTANCE(device) dc_iostream_isinstance((device), &dc_bluetooth_vtable) #define ISINSTANCE(device) dc_iostream_isinstance((device), &dc_bluetooth_vtable)
struct dc_bluetooth_device_t {
dc_bluetooth_address_t address;
char name[248];
};
#ifdef BLUETOOTH #ifdef BLUETOOTH
static dc_status_t dc_bluetooth_iterator_next (dc_iterator_t *iterator, void *item);
static dc_status_t dc_bluetooth_iterator_free (dc_iterator_t *iterator);
typedef struct dc_bluetooth_iterator_t {
dc_iterator_t base;
dc_descriptor_t *descriptor;
#ifdef _WIN32
HANDLE hLookup;
#else
int fd;
inquiry_info *devices;
size_t count;
size_t current;
#endif
} dc_bluetooth_iterator_t;
static const dc_iterator_vtable_t dc_bluetooth_iterator_vtable = {
sizeof(dc_bluetooth_iterator_t),
dc_bluetooth_iterator_next,
dc_bluetooth_iterator_free,
};
static const dc_iostream_vtable_t dc_bluetooth_vtable = { static const dc_iostream_vtable_t dc_bluetooth_vtable = {
sizeof(dc_socket_t), sizeof(dc_socket_t),
dc_socket_set_timeout, /* set_timeout */ dc_socket_set_timeout, /* set_timeout */
NULL, /* set_break */ dc_socket_set_latency, /* set_latency */
NULL, /* set_dtr */ dc_socket_set_halfduplex, /* set_halfduplex */
NULL, /* set_rts */ dc_socket_set_break, /* set_break */
NULL, /* get_lines */ dc_socket_set_dtr, /* set_dtr */
dc_socket_get_available, /* get_available */ dc_socket_set_rts, /* set_rts */
NULL, /* configure */ dc_socket_get_lines, /* get_lines */
dc_socket_poll, /* poll */ dc_socket_get_available, /* get_received */
dc_socket_configure, /* configure */
dc_socket_read, /* read */ dc_socket_read, /* read */
dc_socket_write, /* write */ dc_socket_write, /* write */
dc_socket_ioctl, /* ioctl */ dc_socket_flush, /* flush */
NULL, /* flush */ dc_socket_purge, /* purge */
NULL, /* purge */
dc_socket_sleep, /* sleep */ dc_socket_sleep, /* sleep */
dc_socket_close, /* close */ dc_socket_close, /* close */
}; };
@ -137,370 +105,11 @@ dc_address_set (bdaddr_t *ba, dc_bluetooth_address_t address)
shift += 8; shift += 8;
} }
} }
static dc_status_t
dc_bluetooth_sdp (uint8_t *port, dc_context_t *context, const bdaddr_t *ba)
{
dc_status_t status = DC_STATUS_SUCCESS;
sdp_session_t *session = NULL;
sdp_list_t *search = NULL, *attrid = NULL;
sdp_list_t *records = NULL;
uint8_t channel = 0;
// Connect to the SDP server on the remote device.
session = sdp_connect (BDADDR_ANY, ba, SDP_RETRY_IF_BUSY);
if (session == NULL) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error;
}
// Specify the UUID of the serial port service with all attributes.
uuid_t uuid = {0};
uint32_t range = 0x0000FFFF;
sdp_uuid16_create (&uuid, SERIAL_PORT_SVCLASS_ID);
search = sdp_list_append (NULL, &uuid);
attrid = sdp_list_append (NULL, &range);
if (search == NULL || attrid == NULL) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error;
}
// Get a list of the service records with their attributes.
if (sdp_service_search_attr_req (session, search, SDP_ATTR_REQ_RANGE, attrid, &records) != 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error;
}
// Go through each of the service records.
for (sdp_list_t *r = records; r; r = r->next ) {
sdp_record_t *record = (sdp_record_t *) r->data;
// Get a list of the protocol sequences.
sdp_list_t *protos = NULL;
if (sdp_get_access_protos (record, &protos) != 0 ) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error;
}
// Get the rfcomm port number.
int ch = sdp_get_proto_port (protos, RFCOMM_UUID);
sdp_list_foreach (protos, (sdp_list_func_t) sdp_list_free, NULL);
sdp_list_free (protos, NULL);
if (ch > 0) {
channel = ch;
break;
}
}
if (channel == 0) {
ERROR (context, "No serial port service found!");
status = DC_STATUS_IO;
goto error;
}
INFO (context, "SDP: channel=%u", channel);
*port = channel;
error:
sdp_list_free (records, (sdp_free_func_t) sdp_record_free);
sdp_list_free (attrid, NULL);
sdp_list_free (search, NULL);
sdp_close (session);
return status;
}
#endif #endif
#endif #endif
char *
dc_bluetooth_addr2str(dc_bluetooth_address_t address, char *str, size_t size)
{
if (str == NULL || size < DC_BLUETOOTH_SIZE)
return NULL;
int n = dc_platform_snprintf(str, size, "%02X:%02X:%02X:%02X:%02X:%02X",
(unsigned char)((address >> 40) & 0xFF),
(unsigned char)((address >> 32) & 0xFF),
(unsigned char)((address >> 24) & 0xFF),
(unsigned char)((address >> 16) & 0xFF),
(unsigned char)((address >> 8) & 0xFF),
(unsigned char)((address >> 0) & 0xFF));
if (n < 0 || (size_t) n >= size)
return NULL;
return str;
}
dc_bluetooth_address_t
dc_bluetooth_str2addr(const char *str)
{
dc_bluetooth_address_t address = 0;
if (str == NULL)
return 0;
unsigned char c = 0;
while ((c = *str++) != '\0') {
if (c == ':') {
continue;
} else if (c >= '0' && c <= '9') {
c -= '0';
} else if (c >= 'A' && c <= 'F') {
c -= 'A' - 10;
} else if (c >= 'a' && c <= 'f') {
c -= 'a' - 10;
} else {
return 0; /* Invalid character! */
}
address <<= 4;
address |= c;
}
return address;
}
dc_bluetooth_address_t
dc_bluetooth_device_get_address (dc_bluetooth_device_t *device)
{
if (device == NULL)
return 0;
return device->address;
}
const char *
dc_bluetooth_device_get_name (dc_bluetooth_device_t *device)
{
if (device == NULL || device->name[0] == '\0')
return NULL;
return device->name;
}
void
dc_bluetooth_device_free (dc_bluetooth_device_t *device)
{
free (device);
}
dc_status_t
dc_bluetooth_iterator_new (dc_iterator_t **out, dc_context_t *context, dc_descriptor_t *descriptor)
{
#ifdef BLUETOOTH
dc_status_t status = DC_STATUS_SUCCESS;
dc_bluetooth_iterator_t *iterator = NULL;
if (out == NULL)
return DC_STATUS_INVALIDARGS;
iterator = (dc_bluetooth_iterator_t *) dc_iterator_allocate (context, &dc_bluetooth_iterator_vtable);
if (iterator == NULL) {
SYSERROR (context, S_ENOMEM);
return DC_STATUS_NOMEMORY;
}
// Initialize the socket library.
status = dc_socket_init (context);
if (status != DC_STATUS_SUCCESS) {
goto error_free;
}
#ifdef _WIN32
WSAQUERYSET wsaq;
memset(&wsaq, 0, sizeof (wsaq));
wsaq.dwSize = sizeof (wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;
HANDLE hLookup = NULL;
if (WSALookupServiceBegin(&wsaq, LUP_CONTAINERS | LUP_FLUSHCACHE, &hLookup) != 0) {
s_errcode_t errcode = S_ERRNO;
if (errcode == WSASERVICE_NOT_FOUND) {
// No remote bluetooth devices found.
hLookup = NULL;
} else {
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error_socket_exit;
}
}
iterator->hLookup = hLookup;
#else
// Get the resource number for the first available bluetooth adapter.
int dev = hci_get_route (NULL);
if (dev < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error_socket_exit;
}
// Open a socket to the bluetooth adapter.
int fd = hci_open_dev (dev);
if (fd < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error_socket_exit;
}
// Perform the bluetooth device discovery. The inquiry lasts for at
// most MAX_PERIODS * 1.28 seconds, and at most MAX_DEVICES devices
// will be returned.
inquiry_info *devices = NULL;
int ndevices = hci_inquiry (dev, MAX_PERIODS, MAX_DEVICES, NULL, &devices, IREQ_CACHE_FLUSH);
if (ndevices < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (context, errcode);
status = dc_socket_syserror(errcode);
goto error_close;
}
iterator->fd = fd;
iterator->devices = devices;
iterator->count = ndevices;
iterator->current = 0;
#endif
iterator->descriptor = descriptor;
*out = (dc_iterator_t *) iterator;
return DC_STATUS_SUCCESS;
#ifndef _WIN32
error_close:
hci_close_dev(fd);
#endif
error_socket_exit:
dc_socket_exit (context);
error_free:
dc_iterator_deallocate ((dc_iterator_t *) iterator);
return status;
#else
return DC_STATUS_UNSUPPORTED;
#endif
}
#ifdef BLUETOOTH
static dc_status_t
dc_bluetooth_iterator_next (dc_iterator_t *abstract, void *out)
{
dc_bluetooth_iterator_t *iterator = (dc_bluetooth_iterator_t *) abstract;
dc_bluetooth_device_t *device = NULL;
#ifdef _WIN32
if (iterator->hLookup == NULL) {
return DC_STATUS_DONE;
}
unsigned char buf[4096];
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
memset(pwsaResults, 0, sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
while (1) {
DWORD dwSize = sizeof(buf);
if (WSALookupServiceNext (iterator->hLookup, LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults) != 0) {
s_errcode_t errcode = S_ERRNO;
if (errcode == WSA_E_NO_MORE || errcode == WSAENOMORE) {
break; // No more results.
}
SYSERROR (abstract->context, errcode);
return dc_socket_syserror(errcode);
}
if (pwsaResults->dwNumberOfCsAddrs == 0 ||
pwsaResults->lpcsaBuffer == NULL ||
pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr == NULL) {
ERROR (abstract->context, "Invalid results returned");
return DC_STATUS_IO;
}
SOCKADDR_BTH *sa = (SOCKADDR_BTH *) pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr;
dc_bluetooth_address_t address = sa->btAddr;
const char *name = (char *) pwsaResults->lpszServiceInstanceName;
#else
while (iterator->current < iterator->count) {
inquiry_info *dev = &iterator->devices[iterator->current++];
dc_bluetooth_address_t address = dc_address_get (&dev->bdaddr);
// Get the user friendly name.
char buf[HCI_MAX_NAME_LENGTH], *name = buf;
int rc = hci_read_remote_name (iterator->fd, &dev->bdaddr, sizeof(buf), buf, 0);
if (rc < 0) {
name = NULL;
}
// Null terminate the string.
buf[sizeof(buf) - 1] = '\0';
#endif
INFO (abstract->context, "Discover: address=" DC_ADDRESS_FORMAT ", name=%s",
address, name ? name : "");
if (!dc_descriptor_filter (iterator->descriptor, DC_TRANSPORT_BLUETOOTH, name)) {
continue;
}
device = (dc_bluetooth_device_t *) malloc (sizeof(dc_bluetooth_device_t));
if (device == NULL) {
SYSERROR (abstract->context, S_ENOMEM);
return DC_STATUS_NOMEMORY;
}
device->address = address;
if (name) {
strncpy(device->name, name, sizeof(device->name) - 1);
device->name[sizeof(device->name) - 1] = '\0';
} else {
memset(device->name, 0, sizeof(device->name));
}
*(dc_bluetooth_device_t **) out = device;
return DC_STATUS_SUCCESS;
}
return DC_STATUS_DONE;
}
static dc_status_t
dc_bluetooth_iterator_free (dc_iterator_t *abstract)
{
dc_bluetooth_iterator_t *iterator = (dc_bluetooth_iterator_t *) abstract;
#ifdef _WIN32
if (iterator->hLookup) {
WSALookupServiceEnd (iterator->hLookup);
}
#else
bt_free(iterator->devices);
hci_close_dev(iterator->fd);
#endif
dc_socket_exit (abstract->context);
return DC_STATUS_SUCCESS;
}
#endif
dc_status_t dc_status_t
dc_bluetooth_open (dc_iostream_t **out, dc_context_t *context, dc_bluetooth_address_t address, unsigned int port) dc_bluetooth_open (dc_iostream_t **out, dc_context_t *context)
{ {
#ifdef BLUETOOTH #ifdef BLUETOOTH
dc_status_t status = DC_STATUS_SUCCESS; dc_status_t status = DC_STATUS_SUCCESS;
@ -509,10 +118,8 @@ dc_bluetooth_open (dc_iostream_t **out, dc_context_t *context, dc_bluetooth_addr
if (out == NULL) if (out == NULL)
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
INFO (context, "Open: address=" DC_ADDRESS_FORMAT ", port=%u", address, port);
// Allocate memory. // Allocate memory.
device = (dc_socket_t *) dc_iostream_allocate (context, &dc_bluetooth_vtable, DC_TRANSPORT_BLUETOOTH); device = (dc_socket_t *) dc_iostream_allocate (context, &dc_bluetooth_vtable);
if (device == NULL) { if (device == NULL) {
SYSERROR (context, S_ENOMEM); SYSERROR (context, S_ENOMEM);
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
@ -528,41 +135,10 @@ dc_bluetooth_open (dc_iostream_t **out, dc_context_t *context, dc_bluetooth_addr
goto error_free; goto error_free;
} }
#ifdef _WIN32
SOCKADDR_BTH sa;
sa.addressFamily = AF_BTH;
sa.btAddr = address;
sa.port = port;
if (port == 0) {
sa.serviceClassId = SerialPortServiceClass_UUID;
} else {
memset(&sa.serviceClassId, 0, sizeof(sa.serviceClassId));
}
#else
struct sockaddr_rc sa;
sa.rc_family = AF_BLUETOOTH;
dc_address_set (&sa.rc_bdaddr, address);
if (port == 0) {
status = dc_bluetooth_sdp (&sa.rc_channel, context, &sa.rc_bdaddr);
if (status != DC_STATUS_SUCCESS) {
goto error_close;
}
} else {
sa.rc_channel = port;
}
#endif
status = dc_socket_connect (&device->base, (struct sockaddr *) &sa, sizeof (sa));
if (status != DC_STATUS_SUCCESS) {
goto error_close;
}
*out = (dc_iostream_t *) device; *out = (dc_iostream_t *) device;
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
error_close:
dc_socket_close (&device->base);
error_free: error_free:
dc_iostream_deallocate ((dc_iostream_t *) device); dc_iostream_deallocate ((dc_iostream_t *) device);
return status; return status;
@ -570,3 +146,168 @@ error_free:
return DC_STATUS_UNSUPPORTED; return DC_STATUS_UNSUPPORTED;
#endif #endif
} }
dc_status_t
dc_bluetooth_discover (dc_iostream_t *abstract, dc_bluetooth_callback_t callback, void *userdata)
{
#ifdef BLUETOOTH
dc_status_t status = DC_STATUS_SUCCESS;
if (!ISINSTANCE (abstract))
return DC_STATUS_INVALIDARGS;
#ifdef _WIN32
WSAQUERYSET wsaq;
memset(&wsaq, 0, sizeof (wsaq));
wsaq.dwSize = sizeof (wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;
HANDLE hLookup;
if (WSALookupServiceBegin(&wsaq, LUP_CONTAINERS | LUP_FLUSHCACHE, &hLookup) != 0) {
s_errcode_t errcode = S_ERRNO;
if (errcode == WSASERVICE_NOT_FOUND) {
// No remote bluetooth devices found.
status = DC_STATUS_SUCCESS;
} else {
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
}
goto error_exit;
}
unsigned char buf[4096];
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
memset(pwsaResults, 0, sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
while (1) {
DWORD dwSize = sizeof(buf);
if (WSALookupServiceNext (hLookup, LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults) != 0) {
s_errcode_t errcode = S_ERRNO;
if (errcode == WSA_E_NO_MORE || errcode == WSAENOMORE) {
break; // No more results.
}
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
goto error_close;
}
if (pwsaResults->dwNumberOfCsAddrs == 0 ||
pwsaResults->lpcsaBuffer == NULL ||
pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr == NULL) {
ERROR (abstract->context, "Invalid results returned");
status = DC_STATUS_IO;
goto error_close;
}
SOCKADDR_BTH *sa = (SOCKADDR_BTH *) pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr;
dc_bluetooth_address_t address = sa->btAddr;
const char *name = (char *) pwsaResults->lpszServiceInstanceName;
INFO (abstract->context, "Discover: address=" DC_ADDRESS_FORMAT ", name=%s", address, name);
if (callback) callback (address, name, userdata);
}
error_close:
WSALookupServiceEnd (hLookup);
#else
// Get the resource number for the first available bluetooth adapter.
int dev = hci_get_route (NULL);
if (dev < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
goto error_exit;
}
// Open a socket to the bluetooth adapter.
int fd = hci_open_dev (dev);
if (fd < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
goto error_exit;
}
// Allocate a buffer to store the results of the discovery.
inquiry_info *devices = (inquiry_info *) malloc (MAX_DEVICES * sizeof(inquiry_info));
if (devices == NULL) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
goto error_close;
}
// Perform the bluetooth device discovery. The inquiry lasts for at
// most MAX_PERIODS * 1.28 seconds, and at most MAX_DEVICES devices
// will be returned.
int ndevices = hci_inquiry (dev, MAX_PERIODS, MAX_DEVICES, NULL, &devices, IREQ_CACHE_FLUSH);
if (ndevices < 0) {
s_errcode_t errcode = S_ERRNO;
SYSERROR (abstract->context, errcode);
status = dc_socket_syserror(errcode);
goto error_free;
}
for (unsigned int i = 0; i < ndevices; ++i) {
dc_bluetooth_address_t address = dc_address_get (&devices[i].bdaddr);
// Get the user friendly name.
char buf[HCI_MAX_NAME_LENGTH], *name = buf;
int rc = hci_read_remote_name (fd, &devices[i].bdaddr, sizeof(buf), buf, 0);
if (rc < 0) {
name = NULL;
}
INFO (abstract->context, "Discover: address=" DC_ADDRESS_FORMAT ", name=%s", address, name);
if (callback) callback (address, name, userdata);
}
error_free:
free(devices);
error_close:
hci_close_dev(fd);
#endif
error_exit:
return status;
#else
return DC_STATUS_UNSUPPORTED;
#endif
}
dc_status_t
dc_bluetooth_connect (dc_iostream_t *abstract, dc_bluetooth_address_t address, unsigned int port)
{
#ifdef BLUETOOTH
dc_socket_t *device = (dc_socket_t *) abstract;
if (!ISINSTANCE (abstract))
return DC_STATUS_INVALIDARGS;
INFO (abstract->context, "Connect: address=" DC_ADDRESS_FORMAT ", port=%d", address, port);
#ifdef _WIN32
SOCKADDR_BTH sa;
sa.addressFamily = AF_BTH;
sa.btAddr = address;
sa.port = port;
memset(&sa.serviceClassId, 0, sizeof(sa.serviceClassId));
#else
struct sockaddr_rc sa;
sa.rc_family = AF_BLUETOOTH;
sa.rc_channel = port;
dc_address_set (&sa.rc_bdaddr, address);
#endif
return dc_socket_connect (&device->base, (struct sockaddr *) &sa, sizeof (sa));
#else
return DC_STATUS_UNSUPPORTED;
#endif
}

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