Compare commits
32 Commits
Subsurface
...
sync-point
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad4bcffa23 | ||
|
|
f103553df1 | ||
|
|
a6274a3a55 | ||
|
|
adfff2d4a7 | ||
|
|
f0e695b089 | ||
|
|
fe2448e34f | ||
|
|
7fd201a400 | ||
|
|
c39dda89bc | ||
|
|
0c8886ce70 | ||
|
|
53ccc4f43b | ||
|
|
8c3e44aa0c | ||
|
|
5dbaa7a053 | ||
|
|
69bd993233 | ||
|
|
a50a1e0688 | ||
|
|
b9e3f40d59 | ||
|
|
f184b45e09 | ||
|
|
0ff1dd15f5 | ||
|
|
fb15ef18f6 | ||
|
|
3a17156be6 | ||
|
|
1f24f67565 | ||
|
|
5ecc65799c | ||
|
|
ddfdb6c306 | ||
|
|
b85f2333be | ||
|
|
06426af656 | ||
|
|
f459155b54 | ||
|
|
ebe6704747 | ||
|
|
5f76249923 | ||
|
|
0ddec2b50f | ||
|
|
8f4038d4cd | ||
|
|
d90417da38 | ||
|
|
f902f5882c | ||
|
|
eac8e98ee7 |
173
.github/workflows/build.yml
vendored
173
.github/workflows/build.yml
vendored
@ -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
|
||||
47
.github/workflows/release.yml
vendored
47
.github/workflows/release.yml
vendored
@ -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 }}
|
||||
39
.gitignore
vendored
39
.gitignore
vendored
@ -32,12 +32,32 @@ Makefile.in
|
||||
/stamp-h1
|
||||
/tags
|
||||
|
||||
/doc/doxygen
|
||||
/doc/doxygen.cfg
|
||||
/doc/html/
|
||||
/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
|
||||
|
||||
@ -47,14 +67,13 @@ Makefile.in
|
||||
/m4/ltsugar.m4
|
||||
/m4/ltversion.m4
|
||||
|
||||
/msvc/x64/
|
||||
/msvc/x86/
|
||||
/msvc/Debug/
|
||||
/msvc/Release/
|
||||
/msvc/*.ncb
|
||||
/msvc/*.suo
|
||||
/msvc/*.vcproj.*.user
|
||||
|
||||
/src/libdivecomputer.exp
|
||||
/src/libdivecomputer.la
|
||||
/src/libdivecomputer.rc
|
||||
/src/revision.h
|
||||
|
||||
/build
|
||||
|
||||
55
.travis.yml
55
.travis.yml
@ -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
|
||||
10
Makefile.am
10
Makefile.am
@ -4,10 +4,6 @@ if ENABLE_EXAMPLES
|
||||
SUBDIRS += examples
|
||||
endif
|
||||
|
||||
if ENABLE_DOC
|
||||
SUBDIRS += doc
|
||||
endif
|
||||
|
||||
AM_MAKEFLAGS = -s
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
@ -16,8 +12,4 @@ pkgconfig_DATA = libdivecomputer.pc
|
||||
|
||||
EXTRA_DIST = \
|
||||
libdivecomputer.pc.in \
|
||||
contrib/README \
|
||||
contrib/android/Android.mk \
|
||||
contrib/msvc/libdivecomputer.vcxproj \
|
||||
contrib/msvc/libdivecomputer.vcxproj.filters \
|
||||
contrib/udev/libdivecomputer.rules
|
||||
msvc/libdivecomputer.vcproj
|
||||
|
||||
162
NEWS
162
NEWS
@ -1,165 +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)
|
||||
==========================
|
||||
|
||||
The v0.6.0 release adds support for several new devices, introduces two
|
||||
new features and fixes a couple of bugs. There are a few minor backwards
|
||||
incompatible changes, but most applications won't be affected by those.
|
||||
|
||||
New features:
|
||||
|
||||
* Add support for new backends:
|
||||
- g2: Scubapro G2, Aladin Sport Matrix, Aladin Square
|
||||
* Add support for many new devices:
|
||||
- Aqualung: i200, i750TC
|
||||
- Cochran: Commander I, II and TM
|
||||
- Cressi: Drake
|
||||
- Hollis: DG02
|
||||
- Mares: Quad
|
||||
- Oceanic: F10
|
||||
- Ratio: iX3M and iDive series
|
||||
- Suunto: D4f, Eon Core
|
||||
- Uwatec: Aladin Tec 3G
|
||||
* Add basic timezone support
|
||||
* Add support for synchronizing the device clock
|
||||
* Document the public api with man pages
|
||||
|
||||
Removed/changed features:
|
||||
|
||||
* Remove the deprecated gas change events
|
||||
* Remove the deprecated vendor_product_parser_create(),
|
||||
vendor_product_device_open() and vendor_product_extract_dives()
|
||||
functions from the public api
|
||||
* Remove the hw_{frog,ostc,ostc3}_device_clock() functions
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* Many small improvements
|
||||
|
||||
Version 0.5.0 (2016-09-30)
|
||||
==========================
|
||||
|
||||
After more than three years of development, the v0.5.0 release is long
|
||||
overdue. The main highlights are the support for many new devices, a few
|
||||
new features and lots of bug fixes. This release is fully backwards
|
||||
compatible with the previous one.
|
||||
|
||||
New features:
|
||||
|
||||
* Add support for new backends:
|
||||
- aqualand: Citizen Hyper Aqualand
|
||||
- commander: Cochran Commander and EMC
|
||||
- eonsteel: Suunto EON Steel
|
||||
- idive: DiveSystem iDive and iX3M
|
||||
- meridian: Scubapro Meridian, Mantis and Chromis
|
||||
- nitekq: Dive Rite NiTek Q
|
||||
* Add support for many new devices:
|
||||
- Aeris: 500 AI, A300, A300CS, F11, XR-1 NX
|
||||
- Aqualung: i300, i450T, i550T
|
||||
- Beuchat: Mundial 2, Mundial 3, Voyager 2G
|
||||
- Cressi: Giotto, Newton
|
||||
- Dive Rite: NiTek Trio
|
||||
- Heinrichs Weikamp: OSTC 2, 3+, 4, cR and Sport
|
||||
- Hollis: TX1
|
||||
- Mares: Airlab, Smart, Smart Apnea, Puck 2
|
||||
- Oceanic: F11, OCi, VTX
|
||||
- Scubapro: XTender 5
|
||||
- Shearwater: Nerd, Perdix, Petrel 2
|
||||
- Sherwood: Amphos, Amphos Air, Vision
|
||||
- Subgear: XP-3G, XP-Air
|
||||
- Suunto: Vyper Novo, Zoop Novo
|
||||
- Tusa: IQ-700
|
||||
- Uwatec: Aladin 2G, Aladin Sport
|
||||
* Add a new sample with the active gas mix.
|
||||
* Add the temperature, tank and divemode fields.
|
||||
* Add support for updating the OSTC and OSTC3 firmware.
|
||||
* Add support for configuring the OSTC3 settings.
|
||||
* Add a new dc_parser_new2 convenience function.
|
||||
|
||||
Removed/changed features:
|
||||
|
||||
* The gas change events (SAMPLE_EVENT_GASCHANGE and
|
||||
SAMPLE_EVENT_GASCHANGE2) have been replaced with the new gasmix
|
||||
sample (DC_SAMPLE_GASMIX). The legacy events are considered
|
||||
deprecated, but kept for backwards compatibility.
|
||||
|
||||
Bug fixes:
|
||||
|
||||
* Many small improvements
|
||||
|
||||
Version 0.4.0 (2013-05-13)
|
||||
==========================
|
||||
|
||||
|
||||
206
configure.ac
206
configure.ac
@ -1,8 +1,8 @@
|
||||
# Versioning.
|
||||
m4_define([dc_version_major],[0])
|
||||
m4_define([dc_version_minor],[9])
|
||||
m4_define([dc_version_minor],[5])
|
||||
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]))
|
||||
|
||||
# Libtool versioning.
|
||||
@ -53,112 +53,41 @@ AC_ARG_ENABLE([examples],
|
||||
[], [enable_examples=yes])
|
||||
AM_CONDITIONAL([ENABLE_EXAMPLES], [test "x$enable_examples" = "xyes"])
|
||||
|
||||
# Documentation.
|
||||
AC_ARG_ENABLE([doc],
|
||||
[AS_HELP_STRING([--enable-doc=@<:@yes/no@:>@],
|
||||
[Build documentation @<:@default=yes@:>@])],
|
||||
[], [enable_doc=yes])
|
||||
AM_CONDITIONAL([ENABLE_DOC], [test "x$enable_doc" = "xyes"])
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_PROG_CC_C99
|
||||
AC_CHECK_PROGS([DOXYGEN], [doxygen])
|
||||
AC_CHECK_PROGS([MANDOC], [mandoc])
|
||||
|
||||
AM_CONDITIONAL([HAVE_DOXYGEN],[test -n "$DOXYGEN"])
|
||||
AM_CONDITIONAL([HAVE_MANDOC],[test -n "$MANDOC"])
|
||||
|
||||
# Enable automake silent build rules.
|
||||
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
|
||||
|
||||
# Checks for operating system.
|
||||
AC_MSG_CHECKING([for operating system])
|
||||
# Checks for native Windows.
|
||||
AC_MSG_CHECKING([for native Win32])
|
||||
case "$host" in
|
||||
*-*-mingw*)
|
||||
platform=windows
|
||||
;;
|
||||
*-*-darwin*)
|
||||
platform=mac
|
||||
os_win32=yes
|
||||
;;
|
||||
*)
|
||||
platform=default
|
||||
os_win32=no
|
||||
;;
|
||||
esac
|
||||
AC_MSG_RESULT([$platform])
|
||||
AM_CONDITIONAL([OS_WIN32], [test "$platform" = "windows"])
|
||||
|
||||
DEPENDENCIES=""
|
||||
AC_MSG_RESULT([$os_win32])
|
||||
AM_CONDITIONAL([OS_WIN32], [test "$os_win32" = "yes"])
|
||||
|
||||
# Checks for USB support.
|
||||
AC_ARG_WITH([libusb],
|
||||
[AS_HELP_STRING([--without-libusb],
|
||||
[Build without the libusb library])],
|
||||
[], [with_libusb=auto])
|
||||
AS_IF([test "x$with_libusb" != "xno"], [
|
||||
PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [have_libusb=yes], [have_libusb=no])
|
||||
AS_IF([test "x$have_libusb" = "xyes"], [
|
||||
AC_DEFINE([HAVE_LIBUSB], [1], [libusb library])
|
||||
DEPENDENCIES="$DEPENDENCIES libusb-1.0"
|
||||
])
|
||||
])
|
||||
|
||||
# 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.
|
||||
AC_ARG_WITH([hidapi],
|
||||
[AS_HELP_STRING([--without-hidapi],
|
||||
[Build without the hidapi library])],
|
||||
[], [with_hidapi=hidapi])
|
||||
AS_IF([test "x$with_hidapi" != "xno"], [
|
||||
PKG_CHECK_MODULES([HIDAPI], [$with_hidapi], [have_hidapi=yes], [have_hidapi=no])
|
||||
AS_IF([test "x$have_hidapi" = "xyes"], [
|
||||
AC_DEFINE([HAVE_HIDAPI], [1], [hidapi library])
|
||||
DEPENDENCIES="$DEPENDENCIES $with_hidapi"
|
||||
])
|
||||
])
|
||||
|
||||
# Checks for BlueZ (bluetooth) support.
|
||||
AC_ARG_WITH([bluez],
|
||||
[AS_HELP_STRING([--without-bluez],
|
||||
[Build without the BlueZ library])],
|
||||
[], [with_bluez=auto])
|
||||
AS_IF([test "x$with_bluez" != "xno"], [
|
||||
PKG_CHECK_MODULES([BLUEZ], [bluez], [have_bluez=yes], [have_bluez=no])
|
||||
AS_IF([test "x$have_bluez" = "xyes"], [
|
||||
AC_DEFINE([HAVE_BLUEZ], [1], [BlueZ library])
|
||||
DEPENDENCIES="$DEPENDENCIES bluez"
|
||||
])
|
||||
])
|
||||
|
||||
AC_SUBST([DEPENDENCIES])
|
||||
|
||||
# Checks for Windows bluetooth support.
|
||||
AC_CHECK_HEADERS([winsock2.h ws2bth.h], , , [
|
||||
#if HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# endif
|
||||
])
|
||||
PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], [have_libusb=yes], [have_libusb=no])
|
||||
if test "$have_libusb" = "yes"; then
|
||||
AC_DEFINE([HAVE_LIBUSB], [1], [libusb support])
|
||||
AC_SUBST([DEPENDENCIES], [libusb-1.0])
|
||||
fi
|
||||
|
||||
# Checks for IrDA support.
|
||||
AC_CHECK_HEADERS([winsock2.h af_irda.h], , , [
|
||||
AC_CHECK_HEADERS([winsock2.h af_irda.h], [irda_win32=yes], [irda_win32=no], [
|
||||
#if HAVE_WINSOCK2_H
|
||||
# include <winsock2.h>
|
||||
# endif
|
||||
])
|
||||
|
||||
AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], , , [
|
||||
AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], [irda_linux=yes], [irda_linux=no], [
|
||||
#if HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
# endif
|
||||
@ -167,55 +96,19 @@ AC_CHECK_HEADERS([sys/socket.h linux/types.h linux/irda.h], , , [
|
||||
# endif
|
||||
])
|
||||
|
||||
if test "$irda_win32" = "yes" || test "$irda_linux" = "yes"; then
|
||||
AC_DEFINE([HAVE_IRDA], [1], [IrDA support])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([IRDA], [test "$irda_win32" = "yes" || test "$irda_linux" = "yes"])
|
||||
|
||||
# Checks for header files.
|
||||
AC_CHECK_HEADERS([linux/serial.h])
|
||||
AC_CHECK_HEADERS([IOKit/serial/ioss.h])
|
||||
AC_CHECK_HEADERS([unistd.h getopt.h])
|
||||
AC_CHECK_HEADERS([sys/param.h])
|
||||
AC_CHECK_HEADERS([pthread.h])
|
||||
AC_CHECK_HEADERS([mach/mach_time.h])
|
||||
|
||||
# Checks for global variable declarations.
|
||||
AC_CHECK_DECLS([optreset])
|
||||
|
||||
# Checks for structures.
|
||||
AC_CHECK_MEMBERS([struct tm.tm_gmtoff],,,[
|
||||
#include <time.h>
|
||||
])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRERROR_R
|
||||
AC_CHECK_FUNCS([localtime_r gmtime_r timegm _mkgmtime])
|
||||
AC_CHECK_FUNCS([clock_gettime mach_absolute_time])
|
||||
AC_CHECK_FUNCS([getopt_long])
|
||||
|
||||
# Checks for supported compiler options.
|
||||
AX_APPEND_COMPILE_FLAGS([-Werror=unknown-warning-option],[ERROR_CFLAGS])
|
||||
AX_APPEND_COMPILE_FLAGS([ \
|
||||
-Wall \
|
||||
-Wshadow \
|
||||
-Wrestrict \
|
||||
-Wformat=2 \
|
||||
-Wwrite-strings \
|
||||
-Wpointer-arith \
|
||||
-Wstrict-prototypes \
|
||||
-Wmissing-prototypes \
|
||||
-Wmissing-declarations \
|
||||
-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])
|
||||
])
|
||||
AC_CHECK_FUNCS([localtime_r gmtime_r])
|
||||
|
||||
# Versioning.
|
||||
AC_SUBST([DC_VERSION],[dc_version])
|
||||
@ -229,25 +122,6 @@ m4_ifset([dc_version_suffix],[
|
||||
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([
|
||||
libdivecomputer.pc
|
||||
Makefile
|
||||
@ -255,41 +129,7 @@ AC_CONFIG_FILES([
|
||||
include/libdivecomputer/Makefile
|
||||
include/libdivecomputer/version.h
|
||||
src/Makefile
|
||||
doc/Makefile
|
||||
doc/doxygen.cfg
|
||||
doc/man/Makefile
|
||||
src/libdivecomputer.rc
|
||||
examples/Makefile
|
||||
])
|
||||
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.
|
||||
])
|
||||
|
||||
@ -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.
|
||||
@ -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)
|
||||
@ -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 > "$(OutDir)libdivecomputer.def" && type "%(FullPath)" >> "$(OutDir)libdivecomputer.def"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo EXPORTS > "$(OutDir)libdivecomputer.def" && type "%(FullPath)" >> "$(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 > "$(OutDir)libdivecomputer.def" && type "%(FullPath)" >> "$(OutDir)libdivecomputer.def"</Command>
|
||||
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo EXPORTS > "$(OutDir)libdivecomputer.def" && type "%(FullPath)" >> "$(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>
|
||||
@ -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>
|
||||
@ -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"
|
||||
@ -1,14 +0,0 @@
|
||||
SUBDIRS = man
|
||||
|
||||
doxygen: doxygen.cfg
|
||||
if HAVE_DOXYGEN
|
||||
$(DOXYGEN) $(DOXYFLAGS) $<
|
||||
touch $@
|
||||
endif
|
||||
|
||||
all-local: doxygen
|
||||
|
||||
clean-local:
|
||||
-$(RM) -rf html latex
|
||||
|
||||
CLEANFILES = doxygen
|
||||
@ -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
|
||||
|
||||
|
||||
2427
doc/doxygen.cfg.in
2427
doc/doxygen.cfg.in
File diff suppressed because it is too large
Load Diff
@ -1,72 +0,0 @@
|
||||
MANPAGES = \
|
||||
dc_buffer_append.3 \
|
||||
dc_buffer_free.3 \
|
||||
dc_buffer_get_data.3 \
|
||||
dc_buffer_get_size.3 \
|
||||
dc_buffer_new.3 \
|
||||
dc_buffer_prepend.3 \
|
||||
dc_context_free.3 \
|
||||
dc_context_new.3 \
|
||||
dc_context_set_logfunc.3 \
|
||||
dc_context_set_loglevel.3 \
|
||||
dc_datetime_gmtime.3 \
|
||||
dc_datetime_localtime.3 \
|
||||
dc_datetime_mktime.3 \
|
||||
dc_datetime_now.3 \
|
||||
dc_descriptor_free.3 \
|
||||
dc_descriptor_get_model.3 \
|
||||
dc_descriptor_get_product.3 \
|
||||
dc_descriptor_get_vendor.3 \
|
||||
dc_descriptor_get_transports.3 \
|
||||
dc_descriptor_iterator.3 \
|
||||
dc_device_close.3 \
|
||||
dc_device_foreach.3 \
|
||||
dc_device_open.3 \
|
||||
dc_device_set_cancel.3 \
|
||||
dc_device_set_events.3 \
|
||||
dc_device_set_fingerprint.3 \
|
||||
dc_iterator_free.3 \
|
||||
dc_iterator_next.3 \
|
||||
dc_parser_destroy.3 \
|
||||
dc_parser_get_datetime.3 \
|
||||
dc_parser_get_field.3 \
|
||||
dc_parser_new.3 \
|
||||
dc_parser_samples_foreach.3 \
|
||||
dc_bluetooth_open.3 \
|
||||
dc_bluetooth_iterator_new.3 \
|
||||
dc_bluetooth_device_get_address.3 \
|
||||
dc_bluetooth_device_get_name.3 \
|
||||
dc_bluetooth_addr2str.3 \
|
||||
dc_bluetooth_str2addr.3 \
|
||||
dc_bluetooth_device_free.3 \
|
||||
dc_usbhid_open.3 \
|
||||
dc_usbhid_device_get_pid.3 \
|
||||
dc_usbhid_device_get_vid.3 \
|
||||
dc_usbhid_iterator_new.3 \
|
||||
dc_usbhid_device_free.3 \
|
||||
dc_serial_open.3 \
|
||||
dc_serial_device_get_name.3 \
|
||||
dc_serial_iterator_new.3 \
|
||||
dc_serial_device_free.3 \
|
||||
dc_irda_open.3 \
|
||||
dc_irda_device_get_name.3 \
|
||||
dc_irda_device_get_address.3 \
|
||||
dc_irda_iterator_new.3 \
|
||||
dc_irda_device_free.3 \
|
||||
dc_iostream_close.3 \
|
||||
libdivecomputer.3
|
||||
|
||||
HTMLPAGES = $(MANPAGES:%=%.html)
|
||||
|
||||
dist_man_MANS = $(MANPAGES)
|
||||
|
||||
if HAVE_MANDOC
|
||||
doc_DATA = $(HTMLPAGES)
|
||||
endif
|
||||
|
||||
SUFFIXES = .3 .3.html
|
||||
|
||||
.3.3.html:
|
||||
$(AM_V_GEN) $(MANDOC) -Thtml -Ostyle=mandoc.css,man=%N.%S.html $< > $@
|
||||
|
||||
CLEANFILES = $(HTMLPAGES)
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -1,61 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_APPEND 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_append
|
||||
.Nd append to a binary buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft int
|
||||
.Fo dc_buffer_append
|
||||
.Fa "dc_buffer_t *buffer"
|
||||
.Fa "const unsigned char data[]"
|
||||
.Fa "size_t size"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Append
|
||||
.Fa size
|
||||
bytes of
|
||||
.Fa data
|
||||
into the
|
||||
.Fa buffer
|
||||
previously allocated with
|
||||
.Xr dc_buffer_new 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns non-zero on success or zero on memory exhaustion or if
|
||||
.Fa buffer
|
||||
is
|
||||
.Dv NULL .
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_buffer_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,51 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_FREE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_free
|
||||
.Nd free an resizable binary buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft void
|
||||
.Fo dc_buffer_free
|
||||
.Fa "dc_buffer_t *buffer"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Frees a resizable binary buffer created with
|
||||
.Xr dc_buffer_new 3 .
|
||||
It's safe to pass
|
||||
.Dv NULL
|
||||
to this function.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_buffer_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,64 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_GET_DATA 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_get_data
|
||||
.Nd get the data of a buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft "unsigned char *"
|
||||
.Fo dc_buffer_get_data
|
||||
.Fa "dc_buffer_t *buffer"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Get the data used by
|
||||
.Fa buffer ,
|
||||
previously allocated with
|
||||
.Xr dc_buffer_new 3 .
|
||||
For the buffer size, use
|
||||
.Xr dc_buffer_get_size 3 .
|
||||
.Pp
|
||||
The returned pointer is not valid after subsequent calls to change the
|
||||
buffer.
|
||||
.Sh RETURN VALUES
|
||||
Returns the data or
|
||||
.Dv NULL
|
||||
if
|
||||
.Fa buffer
|
||||
is
|
||||
.Dv NULL
|
||||
or no data has been allocated to the buffer.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_buffer_get_size 3 ,
|
||||
.Xr dc_buffer_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,59 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_GET_SIZE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_get_size
|
||||
.Nd get the size used by a buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft size_t
|
||||
.Fo dc_buffer_get_size
|
||||
.Fa "dc_buffer_t *buffer"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Get the number of bytes currently used by
|
||||
.Fa buffer ,
|
||||
previously allocated with
|
||||
.Xr dc_buffer_new 3 .
|
||||
This shouldn't be confused with the capacity, which may be larger.
|
||||
.Pp
|
||||
The returned value is not valid after subsequent calls to change the
|
||||
buffer.
|
||||
.Sh RETURN VALUES
|
||||
Returns the number of bytes used, which may be zero, or zero if
|
||||
.Fa buffer
|
||||
is
|
||||
.Dv NULL .
|
||||
.Sh SEE ALSO
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
.Xr dc_buffer_new 3
|
||||
@ -1,57 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_new
|
||||
.Nd create an resizable binary buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft "dc_buffer_t *"
|
||||
.Fo dc_buffer_new
|
||||
.Fa "size_t capacity"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Create a resizable binary buffer of initial size
|
||||
.Fa capacity ,
|
||||
which may be zero.
|
||||
The created buffer must be freed with
|
||||
.Xr dc_buffer_free 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns a pointer to a
|
||||
.Vt dc_buffer_t
|
||||
or
|
||||
.Dv NULL
|
||||
on memory exhaustion.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_buffer_free 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,61 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_BUFFER_PREPEND 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_buffer_prepend
|
||||
.Nd prepend to a binary buffer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/buffer.h
|
||||
.Ft int
|
||||
.Fo dc_buffer_prepend
|
||||
.Fa "dc_buffer_t *buffer"
|
||||
.Fa "const unsigned char data[]"
|
||||
.Fa "size_t size"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Prepend
|
||||
.Fa size
|
||||
bytes of
|
||||
.Fa data
|
||||
to the beginning of
|
||||
.Fa buffer
|
||||
previously allocated with
|
||||
.Xr dc_buffer_new 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns non-zero on success or zero on memory exhaustion or if
|
||||
.Fa buffer
|
||||
is
|
||||
.Dv NULL .
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_buffer_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,54 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_CONTEXT_FREE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_context_free
|
||||
.Nd free a device-handling context
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/context.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_context_free
|
||||
.Fa "dc_context_t *context"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Free a context created by
|
||||
.Xr dc_context_new 3 .
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_OK
|
||||
on success or if the pointer is
|
||||
.Dv NULL .
|
||||
Otherwise, it returns an error code.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,73 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_CONTEXT_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_context_new
|
||||
.Nd create a new device-handling context
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/context.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_context_new
|
||||
.Fa "dc_context_t **context"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Create a context in which dive computers may be queried.
|
||||
The
|
||||
.Dq context
|
||||
supplies logging messages and so on, and may be re-used for multiple
|
||||
dive computer query sessions.
|
||||
It is usually passed to
|
||||
.Xr dc_device_open 3
|
||||
to query a specific dive computer device.
|
||||
.Pp
|
||||
On success, the context must be freed with
|
||||
.Xr dc_context_free 3 .
|
||||
You may configure the context with
|
||||
.Xr dc_context_set_loglevel 3
|
||||
and
|
||||
.Xr dc_context_set_logfunc 3 .
|
||||
This is highly recommended as the default logging behaviour of
|
||||
.Nm
|
||||
depends upon compile-time values.
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_OK
|
||||
on success, in which case
|
||||
.Fa context
|
||||
is filled in, or an error code on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_free 3 ,
|
||||
.Xr dc_context_set_logfunc 3 ,
|
||||
.Xr dc_context_set_loglevel 3 ,
|
||||
.Xr dc_device_open 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,98 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_CONTEXT_SET_LOGFUNC 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_context_set_logfunc
|
||||
.Nd set the logging function for a dive computer context
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/context.h
|
||||
.Ft typedef void
|
||||
.Fo (*dc_logfunc_t)
|
||||
.Fa "dc_context_t *context"
|
||||
.Fa "dc_loglevel_t loglevel"
|
||||
.Fa "const char *file"
|
||||
.Fa "unsigned int line"
|
||||
.Fa "const char *function"
|
||||
.Fa "const char *message"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_context_set_logfunc
|
||||
.Fa "dc_context_t *context"
|
||||
.Fa "dc_logfunc_t logfunc"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Set the logging function
|
||||
.Fa logfunc
|
||||
associated with a dive computer context.
|
||||
The logging function is invoked with argument
|
||||
.Fa userdata
|
||||
when the log level
|
||||
.Pq see Xr dc_context_set_loglevel 3
|
||||
has been exceeded.
|
||||
.Pp
|
||||
The
|
||||
.Fa logfunc
|
||||
accepts the following values:
|
||||
.Bl -tag -width Ds
|
||||
.It Fa context
|
||||
The context in which it was invoked.
|
||||
.It Fa loglevel
|
||||
The level of the log message.
|
||||
.It Fa file
|
||||
The source file where the message was raised.
|
||||
.It Fa line
|
||||
The source line (from 1) where the message was raised.
|
||||
.It Fa function
|
||||
The function that raised the log message.
|
||||
.It Fa message
|
||||
The log message itself.
|
||||
.It Fa userdata
|
||||
The pointer passed to
|
||||
.Nm dc_context_set_logfunc .
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_OK
|
||||
on setting the log level,
|
||||
.Dv DC_STATUS_INVALIDARGS
|
||||
if
|
||||
.Fa context
|
||||
is
|
||||
.Dv NULL ,
|
||||
or another error code on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_new 3 ,
|
||||
.Xr dc_context_set_loglevel 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,90 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_CONTEXT_SET_LOGLEVEL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_context_set_loglevel
|
||||
.Nd set the logging level for a dive computer context
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/context.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_context_set_loglevel
|
||||
.Fa "dc_context_t *context"
|
||||
.Fa "dc_loglevel_t loglevel"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Set the
|
||||
.Em minimum
|
||||
log level required to raise a logging event with the
|
||||
.Xr dc_context_set_logfunc 3
|
||||
callback.
|
||||
Operates on a dive computer context created with
|
||||
.Xr dc_context_new 3 .
|
||||
The log levels are ordered as follows:
|
||||
.Bl -enum
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_NONE
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_ERROR
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_WARNING
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_INFO
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_DEBUG
|
||||
.It
|
||||
.Dv DC_LOGLEVEL_ALL
|
||||
.El
|
||||
.Pp
|
||||
By setting, for exammple,
|
||||
.Dv DC_LOGLEVEL_INFO ,
|
||||
all events of
|
||||
.Dv DC_LOGLEVEL_ERROR ,
|
||||
.Dv DC_LOGLEVEL_WARNING ,
|
||||
and
|
||||
.Dv DC_LOGLEVEL_INFO
|
||||
will be reported via the callback in
|
||||
.Xr dc_context_set_logfunc 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_OK
|
||||
on setting the log level,
|
||||
.Dv DC_STATUS_INVALIDARGS
|
||||
if
|
||||
.Fa context
|
||||
is
|
||||
.Dv NULL ,
|
||||
or another error code on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_new 3 ,
|
||||
.Xr dc_context_set_logfunc 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,94 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 11, 2017
|
||||
.Dt DC_DATETIME_GMTIME 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_datetime_gmtime
|
||||
.Nd convert an timestamp to GMT date and time
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/datetime.h
|
||||
.Ft dc_datetime_t *
|
||||
.Fo dc_datetime_gmtime
|
||||
.Fa "dc_datetime_t *result"
|
||||
.Fa "dc_ticks_t ticks"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Convert an integral timestamp
|
||||
.Fa ticks
|
||||
created with
|
||||
.Xr dc_datetime_now 3
|
||||
or
|
||||
.Xr dc_datetime_mktime 3
|
||||
into a broken-down GMT representation in
|
||||
.Fa result .
|
||||
The filled-in value consists of the
|
||||
.Va year ,
|
||||
.Va month ,
|
||||
.Va day ,
|
||||
.Va hour ,
|
||||
.Va minute ,
|
||||
and
|
||||
.Va second
|
||||
fields.
|
||||
.Pp
|
||||
.Em Note :
|
||||
unlike in
|
||||
.Vt "struct tm" ,
|
||||
the value for
|
||||
.Va year
|
||||
is normalised, not less 1900; moreover, the value for
|
||||
.Va month
|
||||
is from one, not zero.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function may internally invoke libc's
|
||||
.Xr gmtime 3 ,
|
||||
or if available,
|
||||
.Xr gmtime_r 3 .
|
||||
.Sh RETURN VALUES
|
||||
This returns the
|
||||
.Fa result
|
||||
pointer on success.
|
||||
It returns
|
||||
.Dv NULL
|
||||
if
|
||||
.Fa ticks
|
||||
cannot be sanely converted or if
|
||||
.Fa result
|
||||
is
|
||||
.Dv NULL .
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_datetime_localtime 3 ,
|
||||
.Xr dc_datetime_mktime 3 ,
|
||||
.Xr dc_datetime_now 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,94 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 11, 2017
|
||||
.Dt DC_DATETIME_LOCALTIME 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_datetime_localtime
|
||||
.Nd convert an timestamp to local date and time
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/datetime.h
|
||||
.Ft dc_datetime_t *
|
||||
.Fo dc_datetime_localtime
|
||||
.Fa "dc_datetime_t *result"
|
||||
.Fa "dc_ticks_t ticks"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Convert an integral timestamp
|
||||
.Fa ticks
|
||||
created with
|
||||
.Xr dc_datetime_now 3
|
||||
or
|
||||
.Xr dc_datetime_mktime 3
|
||||
into a broken-down local-time representation in
|
||||
.Fa result .
|
||||
The filled-in value consists of the
|
||||
.Va year ,
|
||||
.Va month ,
|
||||
.Va day ,
|
||||
.Va hour ,
|
||||
.Va minute ,
|
||||
and
|
||||
.Va second
|
||||
fields.
|
||||
.Pp
|
||||
.Em Note :
|
||||
unlike in
|
||||
.Vt "struct tm" ,
|
||||
the value for
|
||||
.Va year
|
||||
is normalised, not less 1900; moreover, the value for
|
||||
.Va month
|
||||
is from one, not zero.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function may internally invoke libc's
|
||||
.Xr localtime 3 ,
|
||||
or if available,
|
||||
.Xr localtime_r 3 .
|
||||
.Sh RETURN VALUES
|
||||
This returns the
|
||||
.Fa result
|
||||
pointer on success.
|
||||
It returns
|
||||
.Dv NULL
|
||||
if
|
||||
.Fa ticks
|
||||
cannot be sanely converted or if
|
||||
.Fa result
|
||||
is
|
||||
.Dv NULL .
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_datetime_gmtime 3 ,
|
||||
.Xr dc_datetime_mktime 3 ,
|
||||
.Xr dc_datetime_now 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,59 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 11, 2017
|
||||
.Dt DC_DATETIME_MKTIME 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_datetime_mktime
|
||||
.Nd convert an local date and time to a timestamp
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/datetime.h
|
||||
.Ft dc_ticks_t
|
||||
.Fo dc_datetime_mktime
|
||||
.Fa "const dc_datetime_t *dt"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Convert a broken-down local date and time created with
|
||||
.Xr dc_datetime_localtime 3
|
||||
into an integral timestamp.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function may internally invoke libc's
|
||||
.Xr mktime 3 .
|
||||
.Sh RETURN VALUES
|
||||
This returns the integral time-stamp or -1 if the given date and time
|
||||
may not sanely be converted.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_datetime_gmtime 3 ,
|
||||
.Xr dc_datetime_localtime 3 ,
|
||||
.Xr dc_datetime_now 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,55 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 11, 2017
|
||||
.Dt DC_DATETIME_NOW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_datetime_now
|
||||
.Nd return the current integral timestamp
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/datetime.h
|
||||
.Ft dc_ticks_t
|
||||
.Fo dc_datetime_now
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Get the current system timestamp as an integral value.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function may invoke libc's
|
||||
.Xr time 3 .
|
||||
.Sh RETURN VALUES
|
||||
This always returns the system time.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_datetime_gmtime 3 ,
|
||||
.Xr dc_datetime_localtime 3 ,
|
||||
.Xr dc_datetime_mktime 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,54 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DESCRIPTOR_FREE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_descriptor_free
|
||||
.Nd free a dive computer descriptor reference
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/descriptor.h
|
||||
.Ft void
|
||||
.Fo dc_descriptor_free
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Frees a descriptor usually returned with
|
||||
.Xr dc_iterator_next 3
|
||||
as created with
|
||||
.Xr dc_descriptor_iterator 3 .
|
||||
It's safe to pass
|
||||
.Dv NULL
|
||||
to this function.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_descriptor_iterator 3 ,
|
||||
.Xr dc_iterator_free 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,52 +0,0 @@
|
||||
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2018 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 August 19, 2018
|
||||
.Dt DC_DESCRIPTOR_GET_MODEL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_descriptor_get_model
|
||||
.Nd get the model of a dive computer descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/descriptor.h
|
||||
.Ft "unsigned int"
|
||||
.Fo dc_descriptor_get_model
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Gets the model number of a dive computer descriptor or 0 if none was
|
||||
defined for the computer.
|
||||
0 is also a valid model number.
|
||||
.Sh RETURN VALUES
|
||||
This returns the model number or 0 if none exists.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_descriptor_iterator 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,59 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DESCRIPTOR_GET_PRODUCT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_descriptor_get_product
|
||||
.Nd get the product of a dive computer descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/descriptor.h
|
||||
.Ft "const char *"
|
||||
.Fo dc_descriptor_get_product
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Gets the product
|
||||
.Pq e.g., Do D6i Dc for my Suunto
|
||||
of a dive computer descriptor or
|
||||
.Dv NULL
|
||||
if none was declared.
|
||||
.Sh RETURN VALUES
|
||||
This returns the nil-terminated product string or
|
||||
.Dv NULL
|
||||
if none exists.
|
||||
.Pp
|
||||
The returned pointer is not valid after the
|
||||
.Fa descriptor
|
||||
has been freed.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_descriptor_get_vendor 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -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 .
|
||||
@ -1,59 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DESCRIPTOR_GET_VENDOR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_descriptor_get_vendor
|
||||
.Nd get the vendor of a dive computer descriptor
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/descriptor.h
|
||||
.Ft "const char *"
|
||||
.Fo dc_descriptor_get_vendor
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Gets the vendor
|
||||
.Pq e.g., Dq Suunto
|
||||
of a dive computer descriptor or
|
||||
.Dv NULL
|
||||
if none was declared.
|
||||
.Sh RETURN VALUES
|
||||
This returns the nil-terminated vendor string or
|
||||
.Dv NULL
|
||||
if none exists.
|
||||
.Pp
|
||||
The returned pointer is not valid after the
|
||||
.Fa descriptor
|
||||
has been freed.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_descriptor_get_product 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,78 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DESCRIPTOR_ITERATOR 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_descriptor_iterator
|
||||
.Nd get all supported dive computers
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/descriptor.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_descriptor_iterator
|
||||
.Fa "dc_iterator_t **iterator"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Gets all descriptors available to
|
||||
.Lb libdivecomputer .
|
||||
It must be matched with
|
||||
.Xr dc_iterator_free 3
|
||||
if the return value is
|
||||
.Dv DC_STATUS_SUCCESS .
|
||||
The
|
||||
.Xr dc_iterator_next 3
|
||||
function must be used to iterate over the iterator.
|
||||
You must use
|
||||
.Xr dc_descriptor_free 3
|
||||
on the returned descriptor value.
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
and fills in the
|
||||
.Fa iterator
|
||||
pointer on success.
|
||||
.Sh EXAMPLES
|
||||
The following iterates over all descriptors, printing the vendor, then
|
||||
frees the iterator.
|
||||
It does no error checking.
|
||||
.Bd -literal
|
||||
dc_descriptor_iterator(&iter));
|
||||
while (dc_iterator_next(iter, &desc) == DC_STATUS_SUCCESS) {
|
||||
printf("%s\en", dc_descriptor_get_vendor(desc));
|
||||
dc_descriptor_free(desc);
|
||||
}
|
||||
dc_iterator_free(iter);
|
||||
.Ed
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_descriptor_free 3 ,
|
||||
.Xr dc_iterator_free 3 ,
|
||||
.Xr dc_iterator_next 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,58 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DEVICE_CLOSE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_close
|
||||
.Nd close a dive computer device
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_close
|
||||
.Fa "dc_device_t *device"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Closes a dive computer device opened with
|
||||
.Xr dc_device_open 3 .
|
||||
If
|
||||
.Fa device
|
||||
is
|
||||
.Dv NULL ,
|
||||
this returns
|
||||
.Dv DC_STATUS_SUCCESS .
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success or one of several error values on error.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_device_open 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,84 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DEVICE_FOREACH 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_foreach
|
||||
.Nd iterate over dives in a dive computer
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft typedef int
|
||||
.Fo (*dc_dive_callback_t)
|
||||
.Fa "const unsigned char *data"
|
||||
.Fa "unsigned int size"
|
||||
.Fa "const unsigned char *fingerprint"
|
||||
.Fa "unsigned int fsize"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_foreach
|
||||
.Fa "dc_device_t *device"
|
||||
.Fa "dc_dive_callback_t callback"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Iterate over all dives on
|
||||
.Fa device
|
||||
by calling
|
||||
.Fa callback
|
||||
with
|
||||
.Fa userdata .
|
||||
.Pp
|
||||
Each dive invokes
|
||||
.Fa callback
|
||||
with the dive data, which should be parsed with
|
||||
.Xr dc_parser_new 3 ,
|
||||
and the binary fingerprint of the dive.
|
||||
The fingerprint can be used to record the newest dive and stop
|
||||
processing (on subsequent invocations) when the same dive fingerprint is
|
||||
encountered.
|
||||
.Pp
|
||||
The
|
||||
.Fa callback
|
||||
function must return non-zero to continue downloading dives, or zero to
|
||||
stop.
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success or one of several error values on error.
|
||||
If
|
||||
.Fa callback
|
||||
returns zero, this will not be reflected in the return value (usually
|
||||
.Dv DC_STATUS_SUCCESS ) .
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,87 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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_DEVICE_OPEN 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_open
|
||||
.Nd open a dive computer device
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_open
|
||||
.Fa "dc_device_t **device"
|
||||
.Fa "dc_context_t *context"
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fa "dc_iostream_t *iostream"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Open a dive computer device for processing.
|
||||
Accepts a
|
||||
.Fa context
|
||||
opened with
|
||||
.Xr dc_context_new 3 ,
|
||||
a dive computer
|
||||
.Fa descriptor
|
||||
usually found by searching through
|
||||
.Xr dc_descriptor_iterator 3 ,
|
||||
and a
|
||||
.Fa iostream
|
||||
opened with a transport specific open function like
|
||||
.Xr dc_usbhid_open 3 ,
|
||||
.Xr dc_irda_open 3 ,
|
||||
.Xr dc_serial_open 3 ,
|
||||
or
|
||||
.Xr dc_bluetooth_open 3
|
||||
.Pc .
|
||||
.Pp
|
||||
Upon returning
|
||||
.Dv DC_STATUS_SUCCESS ,
|
||||
the
|
||||
.Fa device
|
||||
pointer must be freed with
|
||||
.Xr dc_device_close 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success or one of several error values on error.
|
||||
On success, the
|
||||
.Fa device
|
||||
pointer is filled in with an open handle.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_new 3 ,
|
||||
.Xr dc_descriptor_iterator 3 ,
|
||||
.Xr dc_device_close 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
.br
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
and
|
||||
.An Vincent Hagen ,
|
||||
.Mt vinnie@script4web.nl
|
||||
@ -1,79 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DEVICE_SET_CANCEL 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_set_cancel
|
||||
.Nd callback to check whether processing should cancel
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft "typedef int"
|
||||
.Fo "(*dc_cancel_callback_t)"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_set_cancel
|
||||
.Fa "dc_device_t *device"
|
||||
.Fa "dc_cancel_callback_t callback"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Provide a function that the underlying
|
||||
.Fa device
|
||||
will periodically call to see if it should cancel its processing.
|
||||
The
|
||||
.Fa callback
|
||||
will return zero if the operation should not be cancelled, one if it
|
||||
should be cancelled.
|
||||
.Pp
|
||||
The callback usually checks a value that is set during a signal handling
|
||||
callback.
|
||||
For example, one can invoke
|
||||
.Xr signal 3
|
||||
to a function that sets a
|
||||
.Vt "volatile sig_atomic_t"
|
||||
value checked by the
|
||||
.Fa callback
|
||||
handler.
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_UNSUPPORTED
|
||||
if the
|
||||
.Fa device
|
||||
is
|
||||
.Dv NULL ,
|
||||
or
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
otherwise.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_device_open 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
These manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,125 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DEVICE_SET_EVENTS 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_set_events
|
||||
.Nd set events logged during device interaction
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft "typedef void"
|
||||
.Fo "(*dc_event_callback_t)"
|
||||
.Fa "dc_device_t *device"
|
||||
.Fa "dc_event_type_t event"
|
||||
.Fa "const void *data"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_set_events
|
||||
.Fa "dc_device_t *device"
|
||||
.Fa "unsigned int events"
|
||||
.Fa "dc_event_callback_t callback"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Register a series of event callbacks on a device opened with
|
||||
.Xr dc_device_open 3 .
|
||||
Event callbacks are informative messages during device processing passed
|
||||
to the
|
||||
.Fa callback
|
||||
function with an optional argument
|
||||
.Fa userdata.
|
||||
.Pp
|
||||
The
|
||||
.Fa events
|
||||
value is a bit-field of events, one of which is passed to the
|
||||
.Fa callback
|
||||
as
|
||||
.Fa event .
|
||||
The
|
||||
.Fa data
|
||||
field will be cast to an event-specific type:
|
||||
.Bl -tag -width Ds
|
||||
.It Dv DC_EVENT_WAITING
|
||||
Indicate that the device is waiting for user input, such as activating
|
||||
the data transfer mode on the device.
|
||||
No
|
||||
.Fa data
|
||||
is set.
|
||||
.It Dv DC_EVENT_PROGRESS
|
||||
Progress metre of the parse.
|
||||
The
|
||||
.Fa data
|
||||
variable is set to a
|
||||
.Vt dc_event_progress_t ,
|
||||
with the
|
||||
.Va current
|
||||
and
|
||||
.Va maximum
|
||||
progress values from which one can compute a percentage.
|
||||
.It Dv DC_EVENT_DEVINFO
|
||||
Sets the
|
||||
.Fa data
|
||||
value to a
|
||||
.Vt dc_event_devinfo_t ,
|
||||
which can be used to acquire the
|
||||
.Va model ,
|
||||
.Va firmware ,
|
||||
and
|
||||
.Va serial
|
||||
numbers of the underlying device.
|
||||
.It Dv DC_EVENT_CLOCK
|
||||
Report the system (local machine) and device time in epoch seconds.
|
||||
Fills in
|
||||
.Fa data
|
||||
as a
|
||||
.Va dc_event_clock_t ,
|
||||
with
|
||||
.Va devtime
|
||||
being the device and
|
||||
.Va systime
|
||||
being the system time.
|
||||
See
|
||||
.Xr time 3 .
|
||||
.It Dv DC_EVENT_VENDOR
|
||||
A vendor-specific event filling
|
||||
.Fa data
|
||||
as a
|
||||
.Va dc_event_vendor_t .
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success or one of several error values on error.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_device_open 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
These manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,70 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_DEVICE_SET_FINGERPRINT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_device_set_fingerprint
|
||||
.Nd set the last-seen dive fingerprint
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/device.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_device_set_fingerprint
|
||||
.Fa "dc_device_t *device"
|
||||
.Fa "const unsigned char data[]"
|
||||
.Fa "unsigned int size"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Sets the last-seen dive fingerprint on a device opened with
|
||||
.Xr dc_device_open 3 .
|
||||
This mechanism is used to only download dives
|
||||
.Dq newer
|
||||
.Po
|
||||
as reported by the dive computer, not necessarily on the calendar
|
||||
.Pc
|
||||
than the last seen dive.
|
||||
.Pp
|
||||
In general usage, the fingerprint is acquired (and saved) from the first
|
||||
dive downloaded from a dive computer by
|
||||
.Xr dc_device_foreach 3 .
|
||||
In subsequent openings of the device, the fingerprint is set with
|
||||
.Nm
|
||||
and, when a dive reports a fingerprint matching that dive, the download
|
||||
exits before reporting that dive.
|
||||
.Pq The first fingerprint is saved again for subsequent invocations.
|
||||
In this way, only the newest dives are reported.
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
if the fingerprint was set or one of several error values on error.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_device_open 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -1,56 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_ITERATOR_FREE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_iterator_free
|
||||
.Nd frees an iterator
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/iterator.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_iterator_free
|
||||
.Fa "dc_iterator_t *iterator"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Frees the iterator
|
||||
.Fa iterator .
|
||||
It may be invoked on any iterator type, e.g., one created with
|
||||
.Xr dc_descriptor_iterator 3 .
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success (or if
|
||||
.Fa iterator
|
||||
is
|
||||
.Dv NULL )
|
||||
or other values on failure.
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,55 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_ITERATOR_NEXT 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_iterator_next
|
||||
.Nd next element in an iterator
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/iterator.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_iterator_next
|
||||
.Fa "dc_iterator_t *iterator"
|
||||
.Fa "void *item"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Fills in
|
||||
.Fa item
|
||||
with the next element in the iterator
|
||||
.Fa iterator ,
|
||||
which may not be
|
||||
.Dv NULL .
|
||||
.Sh RETURN VALUES
|
||||
This returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
on success.
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,57 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_PARSER_DESTROY 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_parser_destroy
|
||||
.Nd destroys a single dive parser
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/parser.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_destroy
|
||||
.Fa "dc_parser_t *parser"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Destroys a parser allocated with
|
||||
.Xr dc_parser_new 3 .
|
||||
The
|
||||
.Fa parser
|
||||
parameter may be
|
||||
.Dv NULL ,
|
||||
in which case it will return with success.
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_OK
|
||||
on success and another code on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,69 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_PARSER_GET_DATETIME 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_parser_get_datetime
|
||||
.Nd extract the date and time from a parsed dive
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/parser.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_get_datetime
|
||||
.Fa "dc_parser_t *parser"
|
||||
.Fa "dc_datetime_t *datetime"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Extract the date and time of a dive,
|
||||
.Fa parser ,
|
||||
previously initialised with
|
||||
.Xr dc_parser_new 3 .
|
||||
This returns the broken-down time-stamp of the dive in the local time of
|
||||
the dive.
|
||||
.Pp
|
||||
The
|
||||
.Nm
|
||||
function may internally invoke
|
||||
.Xr dc_datetime_gmtime 3
|
||||
or
|
||||
.Xr dc_datetime_localtime 3 .
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
if the date and time were retrieved,
|
||||
.Dv DC_STATUS_UNSUPPORTED
|
||||
if the date and time are not supported by the device, or other error
|
||||
messages on further failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_datetime_gmtime 3 ,
|
||||
.Xr dc_datetime_localtime 3 ,
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,199 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_PARSER_GET_FIELD 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_parser_get_field
|
||||
.Nd extract a field from a parsed dive
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/parser.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_get_field
|
||||
.Fa "dc_parser_t *parser"
|
||||
.Fa "dc_field_type_t type"
|
||||
.Fa "unsigned int flags"
|
||||
.Fa "void *value"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Extract a field from a dive,
|
||||
.Fa parser ,
|
||||
previously initialised with
|
||||
.Xr dc_parser_new 3 .
|
||||
The
|
||||
.Fa value
|
||||
field type depends upon the
|
||||
.Fa type .
|
||||
The
|
||||
.Fa flags
|
||||
field is ignored for all types but
|
||||
.Dv DC_FIELD_GASMIX
|
||||
and
|
||||
.Dv DC_FIELD_TANK .
|
||||
.Pp
|
||||
The
|
||||
.Fa type
|
||||
may be one of the following values:
|
||||
.Bl -tag -width Ds
|
||||
.It Dv DC_FIELD_DIVETIME
|
||||
Time (duration) of dive in seconds.
|
||||
The
|
||||
.Fa value
|
||||
must be an
|
||||
.Vt unsigned int .
|
||||
.It Dv DC_FIELD_MAXDEPTH
|
||||
Maximum depth in metres.
|
||||
The
|
||||
.Fa value
|
||||
must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_AVGDEPTH
|
||||
Average depth (over all samples) in metres.
|
||||
The
|
||||
.Fa value
|
||||
must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_GASMIX_COUNT
|
||||
Number of different gas mixes used in this dive.
|
||||
The
|
||||
.Fa value
|
||||
must be a
|
||||
.Vt unsigned int .
|
||||
.It Dv DC_FIELD_GASMIX
|
||||
Mixture for a particular gas.
|
||||
The
|
||||
.Fa value
|
||||
must be a
|
||||
.Vt dc_gasmix_t ,
|
||||
which has
|
||||
.Vt double
|
||||
fields for
|
||||
.Va oxygen ,
|
||||
.Va helium ,
|
||||
and
|
||||
.Va nitrogen .
|
||||
These are set to the unit fraction of gas (not percentage).
|
||||
The
|
||||
.Fa flags
|
||||
value is interpreted as the gas mixture index, which must be less than the
|
||||
value of
|
||||
.Dv DC_FIELD_GASMIX_COUNT .
|
||||
.It Dv DC_FIELD_SALINITY
|
||||
The water salinity as a
|
||||
.Vt dc_salinity_t
|
||||
field, which consists of a
|
||||
.Va type ,
|
||||
.Dv DC_WATER_FRESH
|
||||
or
|
||||
.Dv DC_WATER_SALT ,
|
||||
and the salinity
|
||||
.Va density .
|
||||
.It Dv DC_FIELD_ATMOSPHERIC
|
||||
Atmospheric pressure in bar.
|
||||
The
|
||||
.Fa value
|
||||
field must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_TEMPERATURE_SURFACE
|
||||
Air temperature (at the surface) in Celsius.
|
||||
The
|
||||
.Fa value
|
||||
field must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_TEMPERATURE_MINIMUM
|
||||
Minimum water temperature surface in Celsius.
|
||||
The
|
||||
.Fa value
|
||||
field must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_TEMPERATURE_MAXIMUM
|
||||
Maximum water temperature in Celsius.
|
||||
The
|
||||
.Fa value
|
||||
field must be a
|
||||
.Vt double .
|
||||
.It Dv DC_FIELD_TANK_COUNT
|
||||
The number of tanks as an
|
||||
.Vt unsigned int .
|
||||
.It Dv DC_FIELD_TANK
|
||||
Tank configuration as a
|
||||
.Vt dc_tank_t .
|
||||
This structure consists of a
|
||||
.Va gasmix ,
|
||||
which may be retrieved with
|
||||
.Dv DC_FIELD_GASMIX ;
|
||||
.Va type ,
|
||||
the tank volume units as
|
||||
.Dv DC_TANKVOLUME_NONE ,
|
||||
.Dv DC_TANKVOLUME_IMPERIAL ,
|
||||
or
|
||||
.Dv DC_TANKVOLUME_METRIC ;
|
||||
.Va volume ,
|
||||
the tank volume in litres or zero if the tank is
|
||||
.Dv DC_TANKVOLUME_NONE ;
|
||||
.Va workpressure ,
|
||||
the work pressure in bar or zero if
|
||||
.Dv DC_TANKVOLUME_NONE
|
||||
and maybe zero if
|
||||
.Dv DC_TANKVOLUME_METRIC ;
|
||||
.Va beginpressure
|
||||
and
|
||||
.Va endpressure
|
||||
being the pressures at start and finish in bar.
|
||||
The
|
||||
.Fa flags
|
||||
value is the tank index.
|
||||
.It Dv DC_FIELD_DIVEMODE
|
||||
Mode of the dive:
|
||||
.Dv DC_DIVEMODE_FREEDIVE
|
||||
for free-diving,
|
||||
.Dv DC_DIVEMODE_GAUGE
|
||||
for gauge (i.e., running as a record and not computing, say,
|
||||
decompression events),
|
||||
.Dv DC_DIVEMODE_OC
|
||||
for standard open-circuit diving, and
|
||||
.Dv DC_DIVEMODE_CCR
|
||||
and
|
||||
.Dv DC_DIVEMODE_SCR
|
||||
for respectively closed circuit and semi closed circuit
|
||||
.Dq rebreather
|
||||
diving.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_SUCCESS
|
||||
if the field was retrieved,
|
||||
.Dv DC_STATUS_UNSUPPORTED
|
||||
if the field is not supported by the device, or other error messages on
|
||||
further failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,76 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_PARSER_NEW 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_parser_new ,
|
||||
.Nm dc_parser_new2
|
||||
.Nd create a parser for a single dive
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/parser.h
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_new
|
||||
.Fa "dc_parser_t **parser"
|
||||
.Fa "dc_device_t *device"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_new2
|
||||
.Fa "dc_parser_t **parser"
|
||||
.Fa "dc_context_t *context"
|
||||
.Fa "dc_descriptor_t *descriptor"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Creates a parser for a single dive extracted from the dive computer with
|
||||
.Xr dc_device_foreach 3 .
|
||||
The parser operates on the data extracted: it does not touch the device
|
||||
directly to acquire data.
|
||||
Thus, there are two forms of invocation:
|
||||
.Nm dc_parser_new ,
|
||||
which extracts relevant values from the
|
||||
.Fa device
|
||||
parameter; and
|
||||
.Nm dc_parser_new2 ,
|
||||
which is given device values (model, etc.) directly.
|
||||
.Pp
|
||||
The pointer must later be freed with
|
||||
.Xr dc_parser_destroy 3 .
|
||||
.Sh RETURN VALUES
|
||||
These return
|
||||
.Dv DC_STATUS_OK ,
|
||||
and fill in the
|
||||
.Fa parser
|
||||
pointer on success.
|
||||
Otherwise, an error is returned.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_device_foreach 3 ,
|
||||
.Xr dc_parser_destroy 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -1,196 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DC_PARSER_SAMPLES_FOREACH 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm dc_parser_samples_foreach
|
||||
.Nd iterate over samples taken during a dive
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh SYNOPSIS
|
||||
.In libdivecomputer/parser.h
|
||||
.Ft "typedef void"
|
||||
.Fo "(*dc_sample_callback_t)"
|
||||
.Fa "dc_sample_type_t type"
|
||||
.Fa "const dc_sample_value_t *value"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Ft dc_status_t
|
||||
.Fo dc_parser_samples_foreach
|
||||
.Fa "dc_parser_t *parser"
|
||||
.Fa "dc_sample_callback_t callback"
|
||||
.Fa "void *userdata"
|
||||
.Fc
|
||||
.Sh DESCRIPTION
|
||||
Extract the samples taken during a dive as previously initialised with
|
||||
.Xr dc_parser_new 3 .
|
||||
Each sample is passed to
|
||||
.Fa callback
|
||||
with the
|
||||
.Fa type
|
||||
of the sample and its data
|
||||
.Fa value .
|
||||
.Pp
|
||||
Samples are invoked as a sequence of sample sets.
|
||||
Each sequence begins with a
|
||||
.Dv DC_SAMPLE_TIME ,
|
||||
then a number of sample types in the set.
|
||||
When the next
|
||||
.Dv DC_SAMPLE_TIME
|
||||
is recorded, the sample set may be closed and a new one reopened.
|
||||
After all samples have been rendered, the last sample set should be
|
||||
closed.
|
||||
.Pp
|
||||
The following sample types may be raised:
|
||||
.Bl -tag -width Ds
|
||||
.It Dv DC_SAMPLE_TIME
|
||||
The time of the sample taken in milliseconds after the dive began.
|
||||
Set in the
|
||||
.Fa time
|
||||
field.
|
||||
.It Dv DC_SAMPLE_DEPTH
|
||||
The depth taken at the sample in metres.
|
||||
Set in the
|
||||
.Fa depth
|
||||
field.
|
||||
.It Dv DC_SAMPLE_PRESSURE
|
||||
Tank pressure taken at the sample.
|
||||
Sets the
|
||||
.Fa tank
|
||||
index (see the
|
||||
.Dv DC_FIELD_TANK_COUNT
|
||||
in
|
||||
.Xr dc_parser_get_field 3 )
|
||||
and the
|
||||
.Fa pressure
|
||||
in bar.
|
||||
.It Dv DC_SAMPLE_TEMPERATURE
|
||||
Temperature in celsius.
|
||||
Sets the
|
||||
.Fa temperature
|
||||
field.
|
||||
.It Dv DC_SAMPLE_EVENT
|
||||
An diving event raised by the computer.
|
||||
This may have the
|
||||
.Va type
|
||||
value of the
|
||||
.Va event
|
||||
structure set to
|
||||
.Dv SAMPLE_EVENT_NONE ,
|
||||
.Dv SAMPLE_EVENT_DECOSTOP ,
|
||||
.Dv SAMPLE_EVENT_RBT ,
|
||||
.Dv SAMPLE_EVENT_ASCENT ,
|
||||
.Dv SAMPLE_EVENT_CEILING ,
|
||||
.Dv SAMPLE_EVENT_WORKLOAD ,
|
||||
.Dv SAMPLE_EVENT_TRANSMITTER ,
|
||||
.Dv SAMPLE_EVENT_VIOLATION ,
|
||||
.Dv SAMPLE_EVENT_BOOKMARK ,
|
||||
.Dv SAMPLE_EVENT_SURFACE ,
|
||||
.Dv SAMPLE_EVENT_SAFETYSTOP ,
|
||||
.Dv SAMPLE_EVENT_SAFETYSTOP_VOLUNTARY ,
|
||||
.Dv SAMPLE_EVENT_SAFETYSTOP_MANDATORY ,
|
||||
.Dv SAMPLE_EVENT_DEEPSTOP ,
|
||||
.Dv SAMPLE_EVENT_CEILING_SAFETYSTOP ,
|
||||
.Dv SAMPLE_EVENT_FLOOR ,
|
||||
.Dv SAMPLE_EVENT_DIVETIME ,
|
||||
.Dv SAMPLE_EVENT_MAXDEPTH ,
|
||||
.Dv SAMPLE_EVENT_OLF ,
|
||||
.Dv SAMPLE_EVENT_PO2 ,
|
||||
.Dv SAMPLE_EVENT_AIRTIME ,
|
||||
.Dv SAMPLE_EVENT_RGBM ,
|
||||
.Dv SAMPLE_EVENT_HEADING ,
|
||||
or
|
||||
.Dv SAMPLE_EVENT_TISSUELEVEL .
|
||||
.It Dv DC_SAMPLE_RBT
|
||||
The remaining bottom time in seconds.
|
||||
Sets the
|
||||
.Fa rbt
|
||||
field.
|
||||
.It Dv DC_SAMPLE_HEARTBEAT
|
||||
The diver's heartbeat in beats per minute.
|
||||
Sets the
|
||||
.Fa heartbeat
|
||||
field.
|
||||
.It Dv DC_SAMPLE_BEARING
|
||||
The diver's bearing in degrees.
|
||||
Sets the
|
||||
.Fa bearing
|
||||
field.
|
||||
.It Dv DC_SAMPLE_VENDOR
|
||||
A vendor-specific data field.
|
||||
.It Dv DC_SAMPLE_SETPOINT
|
||||
The closed-circuit setpoint (PO2) has changed.
|
||||
Sets the
|
||||
.Fa setpoint
|
||||
value in bar.
|
||||
.It Dv DC_SAMPLE_PPO2
|
||||
The partial pressure of oxygen has changed (in bar).
|
||||
Sets the
|
||||
.Fa ppo2
|
||||
field.
|
||||
.It Dv DC_SAMPLE_CNS
|
||||
The CNS (central nervous system oxygen toxicity) value as a unit
|
||||
fraction.
|
||||
Sets the
|
||||
.Fa cns
|
||||
value.
|
||||
.It Dv DC_SAMPLE_DECO
|
||||
Decompression phase of
|
||||
.Fa type
|
||||
.Dv DC_DECO_NDL
|
||||
.Pq no decompression limit ,
|
||||
.Dv DC_DECO_SAFETYSTOP
|
||||
.Pq the safety stop ,
|
||||
.Dv DC_DECO_DECOSTOP
|
||||
.Pq a decompression stop ,
|
||||
or
|
||||
.Dv DC_DECO_DEEPSTOP
|
||||
.Pq a mandatory or suggested deep-stop .
|
||||
Also sets the
|
||||
.Fa depth
|
||||
in metres and the
|
||||
.Fa time
|
||||
in seconds.
|
||||
.It Dv DC_SAMPLE_GASMIX
|
||||
Switch to a given gas mix index (see the
|
||||
.Dv DC_FIELD_GASMIX_COUNT
|
||||
in
|
||||
.Xr dc_parser_get_field 3 ) .
|
||||
Sets the
|
||||
.Fa gasmix
|
||||
field.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Returns
|
||||
.Dv DC_STATUS_OK
|
||||
on success and another code on failure.
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
The manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -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 .
|
||||
@ -1,159 +0,0 @@
|
||||
.\"
|
||||
.\" libdivecomputer
|
||||
.\"
|
||||
.\" Copyright (C) 2017 Kristaps Dzonsons <kristaps@bsd.lv>
|
||||
.\"
|
||||
.\" 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 January 5, 2017
|
||||
.Dt DIVECOMPUTER 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm divecomputer
|
||||
.Nd communicate with dive computers
|
||||
.Sh LIBRARY
|
||||
.Lb libdivecomputer
|
||||
.Sh DESCRIPTION
|
||||
The
|
||||
.Nm divecomputer
|
||||
library is a cross-platform and open source library for communication
|
||||
with dive computers from various manufacturers.
|
||||
Systems interfacing with
|
||||
.Nm divecomputer
|
||||
must link with
|
||||
.Fl l Ns Ar divecomputer .
|
||||
.Pp
|
||||
A system wishing to query dives in a dive computer generally follows
|
||||
these steps:
|
||||
.Bl -enum
|
||||
.It
|
||||
Create a new context with
|
||||
.Xr dc_context_new 3
|
||||
to initialize the library. Logging can be controlled with
|
||||
.Xr dc_context_set_logfunc 3
|
||||
and
|
||||
.Xr dc_context_set_loglevel 3 .
|
||||
.It
|
||||
Find a descriptor for their dive computer by iterating through
|
||||
.Xr dc_descriptor_iterator 3
|
||||
and searching by name, vendor, or product family.
|
||||
.It
|
||||
Find the transport to use for the communication. To determine the supported transports use
|
||||
.Xr dc_descriptor_get_transports 3 .
|
||||
.It
|
||||
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_fingerprint 3
|
||||
and
|
||||
.Xr dc_device_set_cancel 3
|
||||
to set the logging events, last-seen fingerprint, and cancel routine,
|
||||
respectively.
|
||||
.It
|
||||
Iterate over all dives with
|
||||
.Xr dc_device_foreach 3 .
|
||||
.It
|
||||
For each iterated dive, create a new parser with
|
||||
.Xr dc_parser_new 3 .
|
||||
.It
|
||||
Get attributes of the parsed dive with
|
||||
.Xr dc_parser_get_field 3 .
|
||||
.It
|
||||
Iterate through the dive's samples (recorded data) with
|
||||
.Xr dc_parser_samples_foreach 3 .
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
Most
|
||||
.Nm libdivecomputer
|
||||
functions return with a
|
||||
.Vt dc_status_t
|
||||
type with the following possible values:
|
||||
.Bl -tag -width Ds
|
||||
.It Dv DC_STATUS_SUCCESS
|
||||
Completion with success: not an error.
|
||||
.It Dv DC_STATUS_DONE
|
||||
End of an iterator: not an error.
|
||||
.It Dv DC_STATUS_UNSUPPORTED
|
||||
Feature not implemented or not supported by device.
|
||||
.Po
|
||||
The difference depends on the context.
|
||||
Since
|
||||
.Nm libdivecomputer
|
||||
is largely
|
||||
based on reverse engineering, we often can't even tell them apart.
|
||||
.Pc
|
||||
.It Dv DC_STATUS_INVALIDARGS
|
||||
Invalid parameter.
|
||||
Usually indicates caller bug.
|
||||
.It Dv DC_STATUS_NOMEMORY
|
||||
Out of memory.
|
||||
.It Dv DC_STATUS_NODEVICE
|
||||
Device not found.
|
||||
In this context the device refers to the low-level communication device
|
||||
(serial, bluetooth, irda, etc), not the dive computer.
|
||||
In most cases, and especially with serial communication, we can't detect
|
||||
whether the dive computer is present.
|
||||
This is always detected indirectly: no response is received, and thus a
|
||||
timeout error.
|
||||
.It Dv DC_STATUS_NOACCESS
|
||||
Access denied (again, to the low-level communication device).
|
||||
.It Dv DC_STATUS_TIMEOUT
|
||||
See
|
||||
.Dv DC_STATUS_NODEVICE .
|
||||
.It Dv DC_STATUS_IO
|
||||
Any other I/O error.
|
||||
.It Dv DC_STATUS_PROTOCOL
|
||||
Encountered unexpected data in the communication protocol data packets,
|
||||
e.g., while downloading.
|
||||
.It Dv DC_STATUS_DATAFORMAT
|
||||
Encountered unexpected data in the interpretation of data contents,
|
||||
e.g., while parsing.
|
||||
.It Dv DC_STATUS_CANCELLED
|
||||
Returned when the cancel callback requested to cancel the operation.
|
||||
Note that cancellation is only checked at specific (safe) points, so
|
||||
it's certainly possible it may not get noticed immediately and still
|
||||
return
|
||||
.Dv DC_STATUS_SUCCESS .
|
||||
.El
|
||||
.Sh SEE ALSO
|
||||
.Xr dc_context_new 3 ,
|
||||
.Xr dc_descriptor_iterator 3
|
||||
.Xr dc_device_open 3
|
||||
.Xr dc_parser_new 3
|
||||
.Sh AUTHORS
|
||||
The
|
||||
.Lb libdivecomputer
|
||||
library was written by
|
||||
.An Jef Driesen ,
|
||||
.Mt jef@libdivecomputer.org .
|
||||
These manpages were written by
|
||||
.An Kristaps Dzonsons ,
|
||||
.Mt kristaps@bsd.lv .
|
||||
@ -2,28 +2,12 @@ AM_CPPFLAGS = -I$(top_builddir)/include -I$(top_srcdir)/include
|
||||
LDADD = $(top_builddir)/src/libdivecomputer.la
|
||||
|
||||
bin_PROGRAMS = \
|
||||
dctool
|
||||
universal \
|
||||
ostc-fwupdate
|
||||
|
||||
dctool_SOURCES = \
|
||||
common.h \
|
||||
common.c \
|
||||
dctool.h \
|
||||
dctool.c \
|
||||
dctool_help.c \
|
||||
dctool_version.c \
|
||||
dctool_list.c \
|
||||
dctool_scan.c \
|
||||
dctool_download.c \
|
||||
dctool_dump.c \
|
||||
dctool_parse.c \
|
||||
dctool_read.c \
|
||||
dctool_write.c \
|
||||
dctool_timesync.c \
|
||||
dctool_fwupdate.c \
|
||||
output.h \
|
||||
output-private.h \
|
||||
output.c \
|
||||
output_xml.c \
|
||||
output_raw.c \
|
||||
utils.h \
|
||||
utils.c
|
||||
COMMON = common.c common.h \
|
||||
utils.c utils.h
|
||||
|
||||
universal_SOURCES = universal.c $(COMMON)
|
||||
|
||||
ostc_fwupdate_SOURCES = hw_ostc_fwupdate.c $(COMMON)
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 Jef Driesen
|
||||
* Copyright (C) 2011 Jef Driesen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -19,108 +19,13 @@
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#include <fcntl.h>
|
||||
#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 "utils.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DC_TICKS_FORMAT "%I64d"
|
||||
#else
|
||||
#define DC_TICKS_FORMAT "%lld"
|
||||
#endif
|
||||
|
||||
#define C_ARRAY_SIZE(array) (sizeof (array) / sizeof *(array))
|
||||
|
||||
typedef struct backend_table_t {
|
||||
const char *name;
|
||||
dc_family_t type;
|
||||
unsigned int model;
|
||||
} 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[] = {
|
||||
{"solution", DC_FAMILY_SUUNTO_SOLUTION, 0},
|
||||
{"eon", DC_FAMILY_SUUNTO_EON, 0},
|
||||
{"vyper", DC_FAMILY_SUUNTO_VYPER, 0x0A},
|
||||
{"vyper2", DC_FAMILY_SUUNTO_VYPER2, 0x10},
|
||||
{"d9", DC_FAMILY_SUUNTO_D9, 0x0E},
|
||||
{"eonsteel", DC_FAMILY_SUUNTO_EONSTEEL, 0},
|
||||
{"aladin", DC_FAMILY_UWATEC_ALADIN, 0x3F},
|
||||
{"memomouse", DC_FAMILY_UWATEC_MEMOMOUSE, 0},
|
||||
{"smart", DC_FAMILY_UWATEC_SMART, 0x10},
|
||||
{"sensus", DC_FAMILY_REEFNET_SENSUS, 1},
|
||||
{"sensuspro", DC_FAMILY_REEFNET_SENSUSPRO, 2},
|
||||
{"sensusultra", DC_FAMILY_REEFNET_SENSUSULTRA, 3},
|
||||
{"vtpro", DC_FAMILY_OCEANIC_VTPRO, 0x4245},
|
||||
{"veo250", DC_FAMILY_OCEANIC_VEO250, 0x424C},
|
||||
{"atom2", DC_FAMILY_OCEANIC_ATOM2, 0x4342},
|
||||
{"i330r", DC_FAMILY_PELAGIC_I330R, 0x4744},
|
||||
{"nemo", DC_FAMILY_MARES_NEMO, 0},
|
||||
{"puck", DC_FAMILY_MARES_PUCK, 7},
|
||||
{"darwin", DC_FAMILY_MARES_DARWIN, 0},
|
||||
{"iconhd", DC_FAMILY_MARES_ICONHD, 0x14},
|
||||
{"ostc", DC_FAMILY_HW_OSTC, 0},
|
||||
{"frog", DC_FAMILY_HW_FROG, 0},
|
||||
{"ostc3", DC_FAMILY_HW_OSTC3, 0x0A},
|
||||
{"edy", DC_FAMILY_CRESSI_EDY, 0x08},
|
||||
{"leonardo", DC_FAMILY_CRESSI_LEONARDO, 1},
|
||||
{"goa", DC_FAMILY_CRESSI_GOA, 2},
|
||||
{"n2ition3", DC_FAMILY_ZEAGLE_N2ITION3, 0},
|
||||
{"cobalt", DC_FAMILY_ATOMICS_COBALT, 0},
|
||||
{"predator", DC_FAMILY_SHEARWATER_PREDATOR, 2},
|
||||
{"petrel", DC_FAMILY_SHEARWATER_PETREL, 3},
|
||||
{"nitekq", DC_FAMILY_DIVERITE_NITEKQ, 0},
|
||||
{"aqualand", DC_FAMILY_CITIZEN_AQUALAND, 0},
|
||||
{"idive", DC_FAMILY_DIVESYSTEM_IDIVE, 0x03},
|
||||
{"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 *
|
||||
dctool_errmsg (dc_status_t status)
|
||||
errmsg (dc_status_t rc)
|
||||
{
|
||||
switch (status) {
|
||||
switch (rc) {
|
||||
case DC_STATUS_SUCCESS:
|
||||
return "Success";
|
||||
case DC_STATUS_UNSUPPORTED:
|
||||
@ -148,451 +53,14 @@ dctool_errmsg (dc_status_t status)
|
||||
}
|
||||
}
|
||||
|
||||
dc_family_t
|
||||
dctool_family_type (const char *name)
|
||||
{
|
||||
for (unsigned int i = 0; i < C_ARRAY_SIZE (g_backends); ++i) {
|
||||
if (strcmp (name, g_backends[i].name) == 0)
|
||||
return g_backends[i].type;
|
||||
}
|
||||
|
||||
return DC_FAMILY_NULL;
|
||||
}
|
||||
|
||||
const char *
|
||||
dctool_family_name (dc_family_t type)
|
||||
{
|
||||
for (unsigned int i = 0; i < C_ARRAY_SIZE (g_backends); ++i) {
|
||||
if (g_backends[i].type == type)
|
||||
return g_backends[i].name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
dctool_family_model (dc_family_t type)
|
||||
{
|
||||
for (unsigned int i = 0; i < C_ARRAY_SIZE (g_backends); ++i) {
|
||||
if (g_backends[i].type == type)
|
||||
return g_backends[i].model;
|
||||
}
|
||||
|
||||
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
|
||||
dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
|
||||
logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata)
|
||||
{
|
||||
const dc_event_progress_t *progress = (const dc_event_progress_t *) data;
|
||||
const dc_event_devinfo_t *devinfo = (const dc_event_devinfo_t *) data;
|
||||
const dc_event_clock_t *clock = (const dc_event_clock_t *) data;
|
||||
const dc_event_vendor_t *vendor = (const dc_event_vendor_t *) data;
|
||||
const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"};
|
||||
|
||||
switch (event) {
|
||||
case DC_EVENT_WAITING:
|
||||
message ("Event: waiting for user action\n");
|
||||
break;
|
||||
case DC_EVENT_PROGRESS:
|
||||
message ("Event: progress %3.2f%% (%u/%u)\n",
|
||||
100.0 * (double) progress->current / (double) progress->maximum,
|
||||
progress->current, progress->maximum);
|
||||
break;
|
||||
case DC_EVENT_DEVINFO:
|
||||
message ("Event: model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)\n",
|
||||
devinfo->model, devinfo->model,
|
||||
devinfo->firmware, devinfo->firmware,
|
||||
devinfo->serial, devinfo->serial);
|
||||
break;
|
||||
case DC_EVENT_CLOCK:
|
||||
message ("Event: systime=" DC_TICKS_FORMAT ", devtime=%u\n",
|
||||
clock->systime, clock->devtime);
|
||||
break;
|
||||
case DC_EVENT_VENDOR:
|
||||
message ("Event: vendor=");
|
||||
for (unsigned int i = 0; i < vendor->size; ++i)
|
||||
message ("%02X", vendor->data[i]);
|
||||
message ("\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dctool_descriptor_search (dc_descriptor_t **out, const char *name, dc_family_t family, unsigned int model)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
|
||||
dc_iterator_t *iterator = NULL;
|
||||
rc = dc_descriptor_iterator (&iterator);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error creating the device descriptor iterator.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
dc_descriptor_t *descriptor = NULL, *current = NULL;
|
||||
while ((rc = dc_iterator_next (iterator, &descriptor)) == DC_STATUS_SUCCESS) {
|
||||
if (name) {
|
||||
const char *vendor = dc_descriptor_get_vendor (descriptor);
|
||||
const char *product = dc_descriptor_get_product (descriptor);
|
||||
|
||||
size_t n = strlen (vendor);
|
||||
if (strncasecmp (name, vendor, n) == 0 && name[n] == ' ' &&
|
||||
strcasecmp (name + n + 1, product) == 0)
|
||||
{
|
||||
current = descriptor;
|
||||
break;
|
||||
} else if (strcasecmp (name, product) == 0) {
|
||||
current = descriptor;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (family == dc_descriptor_get_type (descriptor)) {
|
||||
if (model == dc_descriptor_get_model (descriptor)) {
|
||||
// Exact match found. Return immediately.
|
||||
dc_descriptor_free (current);
|
||||
current = descriptor;
|
||||
break;
|
||||
} else {
|
||||
// Possible match found. Keep searching for an exact match.
|
||||
// If no exact match is found, the first match is returned.
|
||||
if (current == NULL) {
|
||||
current = descriptor;
|
||||
descriptor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc_descriptor_free (descriptor);
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_DONE) {
|
||||
dc_descriptor_free (current);
|
||||
dc_iterator_free (iterator);
|
||||
ERROR ("Error iterating the device descriptors.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
dc_iterator_free (iterator);
|
||||
|
||||
*out = current;
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
hex2dec (unsigned char value)
|
||||
{
|
||||
if (value >= '0' && value <= '9')
|
||||
return value - '0';
|
||||
else if (value >= 'A' && value <= 'F')
|
||||
return value - 'A' + 10;
|
||||
else if (value >= 'a' && value <= 'f')
|
||||
return value - 'a' + 10;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
dc_buffer_t *
|
||||
dctool_convert_hex2bin (const char *str)
|
||||
{
|
||||
// Get the length of the fingerprint data.
|
||||
size_t nbytes = (str ? strlen (str) / 2 : 0);
|
||||
if (nbytes == 0)
|
||||
return NULL;
|
||||
|
||||
// Allocate a memory buffer.
|
||||
dc_buffer_t *buffer = dc_buffer_new (nbytes);
|
||||
|
||||
// Convert the hexadecimal string.
|
||||
for (unsigned int i = 0; i < nbytes; ++i) {
|
||||
unsigned char msn = hex2dec (str[i * 2 + 0]);
|
||||
unsigned char lsn = hex2dec (str[i * 2 + 1]);
|
||||
unsigned char byte = (msn << 4) + lsn;
|
||||
|
||||
dc_buffer_append (buffer, &byte, 1);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void
|
||||
dctool_file_write (const char *filename, dc_buffer_t *buffer)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
// Open the file.
|
||||
if (filename) {
|
||||
fp = fopen (filename, "wb");
|
||||
if (loglevel == DC_LOGLEVEL_ERROR || loglevel == DC_LOGLEVEL_WARNING) {
|
||||
message ("%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function);
|
||||
} else {
|
||||
fp = stdout;
|
||||
#ifdef _WIN32
|
||||
// Change from text mode to binary mode.
|
||||
_setmode (_fileno (fp), _O_BINARY);
|
||||
#endif
|
||||
}
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
||||
// Write the entire buffer to the file.
|
||||
fwrite (dc_buffer_get_data (buffer), 1, dc_buffer_get_size (buffer), fp);
|
||||
|
||||
// Close the file.
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
dc_buffer_t *
|
||||
dctool_file_read (const char *filename)
|
||||
{
|
||||
FILE *fp = NULL;
|
||||
|
||||
// Open the file.
|
||||
if (filename) {
|
||||
fp = fopen (filename, "rb");
|
||||
} else {
|
||||
fp = stdin;
|
||||
#ifdef _WIN32
|
||||
// Change from text mode to binary mode.
|
||||
_setmode (_fileno (fp), _O_BINARY);
|
||||
#endif
|
||||
}
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
// Allocate a memory buffer.
|
||||
dc_buffer_t *buffer = dc_buffer_new (0);
|
||||
|
||||
// Read the entire file into the buffer.
|
||||
size_t n = 0;
|
||||
unsigned char block[1024] = {0};
|
||||
while ((n = fread (block, 1, sizeof (block), fp)) > 0) {
|
||||
dc_buffer_append (buffer, block, n);
|
||||
}
|
||||
|
||||
// Close the file.
|
||||
fclose (fp);
|
||||
|
||||
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);
|
||||
message ("%s: %s\n", loglevels[loglevel], msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 Jef Driesen
|
||||
* Copyright (C) 2011 Jef Driesen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -19,58 +19,23 @@
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef DCTOOL_COMMON_H
|
||||
#define DCTOOL_COMMON_H
|
||||
#ifndef EXAMPLES_COMMON_H
|
||||
#define EXAMPLES_COMMON_H
|
||||
|
||||
#include <libdivecomputer/common.h>
|
||||
#include <libdivecomputer/context.h>
|
||||
#include <libdivecomputer/descriptor.h>
|
||||
#include <libdivecomputer/iostream.h>
|
||||
#include <libdivecomputer/device.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
const char *
|
||||
dctool_errmsg (dc_status_t status);
|
||||
|
||||
dc_family_t
|
||||
dctool_family_type (const char *name);
|
||||
|
||||
const char *
|
||||
dctool_family_name (dc_family_t type);
|
||||
|
||||
unsigned int
|
||||
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);
|
||||
errmsg (dc_status_t rc);
|
||||
|
||||
void
|
||||
dctool_event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata);
|
||||
|
||||
dc_status_t
|
||||
dctool_descriptor_search (dc_descriptor_t **out, const char *name, dc_family_t family, unsigned int model);
|
||||
|
||||
dc_buffer_t *
|
||||
dctool_convert_hex2bin (const char *str);
|
||||
|
||||
void
|
||||
dctool_file_write (const char *filename, dc_buffer_t *buffer);
|
||||
|
||||
dc_buffer_t *
|
||||
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);
|
||||
logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DCTOOL_COMMON_H */
|
||||
#endif /* EXAMPLES_COMMON_H */
|
||||
|
||||
@ -1,319 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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 <string.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
#include <libdivecomputer/context.h>
|
||||
#include <libdivecomputer/descriptor.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "dctool.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(__GLIBC__) || defined(__MINGW32__)
|
||||
#define RESET 0
|
||||
#else
|
||||
#define RESET 1
|
||||
#endif
|
||||
|
||||
#if defined(__GLIBC__) || defined(__MINGW32__) || defined(BSD) || defined(__ANDROID__)
|
||||
#define NOPERMUTATION "+"
|
||||
#else
|
||||
#define NOPERMUTATION ""
|
||||
#endif
|
||||
|
||||
static const dctool_command_t *g_commands[] = {
|
||||
&dctool_help,
|
||||
&dctool_version,
|
||||
&dctool_list,
|
||||
&dctool_scan,
|
||||
&dctool_download,
|
||||
&dctool_dump,
|
||||
&dctool_parse,
|
||||
&dctool_read,
|
||||
&dctool_write,
|
||||
&dctool_timesync,
|
||||
&dctool_fwupdate,
|
||||
NULL
|
||||
};
|
||||
|
||||
static volatile sig_atomic_t g_cancel = 0;
|
||||
|
||||
const dctool_command_t *
|
||||
dctool_command_find (const char *name)
|
||||
{
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
|
||||
size_t i = 0;
|
||||
while (g_commands[i] != NULL) {
|
||||
if (strcmp(g_commands[i]->name, name) == 0) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return g_commands[i];
|
||||
}
|
||||
|
||||
void
|
||||
dctool_command_showhelp (const dctool_command_t *command)
|
||||
{
|
||||
if (command == NULL) {
|
||||
unsigned int maxlength = 0;
|
||||
for (size_t i = 0; g_commands[i] != NULL; ++i) {
|
||||
unsigned int length = strlen (g_commands[i]->name);
|
||||
if (length > maxlength)
|
||||
maxlength = length;
|
||||
}
|
||||
printf (
|
||||
"A simple command line interface for the libdivecomputer library\n"
|
||||
"\n"
|
||||
"Usage:\n"
|
||||
" dctool [options] <command> [<args>]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -d, --device <device> Device name\n"
|
||||
" -f, --family <family> Device family type\n"
|
||||
" -m, --model <model> Device model number\n"
|
||||
" -l, --logfile <logfile> Logfile\n"
|
||||
" -q, --quiet Quiet mode\n"
|
||||
" -v, --verbose Verbose mode\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -d <device> Device name\n"
|
||||
" -f <family> Family type\n"
|
||||
" -m <model> Model number\n"
|
||||
" -l <logfile> Logfile\n"
|
||||
" -q Quiet mode\n"
|
||||
" -v Verbose mode\n"
|
||||
#endif
|
||||
"\n"
|
||||
"Available commands:\n");
|
||||
for (size_t i = 0; g_commands[i] != NULL; ++i) {
|
||||
printf (" %-*s%s\n", maxlength + 3, g_commands[i]->name, g_commands[i]->description);
|
||||
}
|
||||
printf ("\nSee 'dctool help <command>' for more information on a specific command.\n\n");
|
||||
} else {
|
||||
printf ("%s\n\n%s\n", command->description, command->usage);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
dctool_cancel_cb (void *userdata)
|
||||
{
|
||||
return g_cancel;
|
||||
}
|
||||
|
||||
static void
|
||||
sighandler (int signum)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
// Restore the default signal handler.
|
||||
signal (signum, SIG_DFL);
|
||||
#endif
|
||||
|
||||
g_cancel = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata)
|
||||
{
|
||||
const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"};
|
||||
|
||||
if (loglevel == DC_LOGLEVEL_ERROR || loglevel == DC_LOGLEVEL_WARNING) {
|
||||
message ("%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function);
|
||||
} else {
|
||||
message ("%s: %s\n", loglevels[loglevel], msg);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_context_t *context = NULL;
|
||||
dc_descriptor_t *descriptor = NULL;
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
dc_loglevel_t loglevel = DC_LOGLEVEL_WARNING;
|
||||
const char *logfile = NULL;
|
||||
const char *device = NULL;
|
||||
dc_family_t family = DC_FAMILY_NULL;
|
||||
unsigned int model = 0;
|
||||
unsigned int have_family = 0, have_model = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = NOPERMUTATION "hd:f:m:l:qv";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"device", required_argument, 0, 'd'},
|
||||
{"family", required_argument, 0, 'f'},
|
||||
{"model", required_argument, 0, 'm'},
|
||||
{"logfile", required_argument, 0, 'l'},
|
||||
{"quiet", no_argument, 0, 'q'},
|
||||
{"verbose", no_argument, 0, 'v'},
|
||||
{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 'd':
|
||||
device = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
family = dctool_family_type (optarg);
|
||||
have_family = 1;
|
||||
break;
|
||||
case 'm':
|
||||
model = strtoul (optarg, NULL, 0);
|
||||
have_model = 1;
|
||||
break;
|
||||
case 'l':
|
||||
logfile = optarg;
|
||||
break;
|
||||
case 'q':
|
||||
loglevel = DC_LOGLEVEL_NONE;
|
||||
break;
|
||||
case 'v':
|
||||
loglevel++;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Skip the processed arguments.
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
optind = RESET;
|
||||
#if defined(HAVE_DECL_OPTRESET) && HAVE_DECL_OPTRESET
|
||||
optreset = 1;
|
||||
#endif
|
||||
|
||||
// Set the default model number.
|
||||
if (have_family && !have_model) {
|
||||
model = dctool_family_model (family);
|
||||
}
|
||||
|
||||
// Translate the help option into a command.
|
||||
char helpcmd[] = "help";
|
||||
char *argv_help[] = {helpcmd, NULL, NULL};
|
||||
if (help || argv[0] == NULL) {
|
||||
if (argv[0]) {
|
||||
argv_help[1] = argv[0];
|
||||
argv = argv_help;
|
||||
argc = 2;
|
||||
} else {
|
||||
argv = argv_help;
|
||||
argc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to find the command.
|
||||
const dctool_command_t *command = dctool_command_find (argv[0]);
|
||||
if (command == NULL) {
|
||||
message ("Unknown command %s.\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Setup the cancel signal handler.
|
||||
signal (SIGINT, sighandler);
|
||||
|
||||
// Initialize the logfile.
|
||||
message_set_logfile (logfile);
|
||||
|
||||
// Initialize a library context.
|
||||
status = dc_context_new (&context);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Setup the logging.
|
||||
dc_context_set_loglevel (context, loglevel);
|
||||
dc_context_set_logfunc (context, logfunc, NULL);
|
||||
|
||||
if (device != NULL || family != DC_FAMILY_NULL) {
|
||||
// Search for a matching device descriptor.
|
||||
status = dctool_descriptor_search (&descriptor, device, family, model);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Fail if no device descriptor found.
|
||||
if (descriptor == NULL) {
|
||||
if (device) {
|
||||
message ("No supported device found: %s\n",
|
||||
device);
|
||||
} else {
|
||||
message ("No supported device found: %s, 0x%X\n",
|
||||
dctool_family_name (family), model);
|
||||
}
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
// 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.
|
||||
exitcode = command->run (argc, argv, context, descriptor);
|
||||
|
||||
cleanup:
|
||||
dc_descriptor_free (descriptor);
|
||||
dc_context_free (context);
|
||||
message_set_logfile (NULL);
|
||||
return exitcode;
|
||||
}
|
||||
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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 DCTOOL_H
|
||||
#define DCTOOL_H
|
||||
|
||||
#include <libdivecomputer/context.h>
|
||||
#include <libdivecomputer/descriptor.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef enum dctool_config_t {
|
||||
DCTOOL_CONFIG_NONE = 0,
|
||||
DCTOOL_CONFIG_DESCRIPTOR = 1,
|
||||
} dctool_config_t;
|
||||
|
||||
typedef struct dctool_command_t {
|
||||
int (*run) (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor);
|
||||
unsigned int config;
|
||||
const char *name;
|
||||
const char *description;
|
||||
const char *usage;
|
||||
} dctool_command_t;
|
||||
|
||||
extern const dctool_command_t dctool_help;
|
||||
extern const dctool_command_t dctool_version;
|
||||
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_dump;
|
||||
extern const dctool_command_t dctool_parse;
|
||||
extern const dctool_command_t dctool_read;
|
||||
extern const dctool_command_t dctool_write;
|
||||
extern const dctool_command_t dctool_timesync;
|
||||
extern const dctool_command_t dctool_fwupdate;
|
||||
|
||||
const dctool_command_t *
|
||||
dctool_command_find (const char *name);
|
||||
|
||||
void
|
||||
dctool_command_showhelp (const dctool_command_t *command);
|
||||
|
||||
int
|
||||
dctool_cancel_cb (void *userdata);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* DCTOOL_H */
|
||||
@ -1,405 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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>
|
||||
#include <string.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/device.h>
|
||||
#include <libdivecomputer/parser.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "output.h"
|
||||
#include "utils.h"
|
||||
|
||||
typedef struct event_data_t {
|
||||
const char *cachedir;
|
||||
dc_event_devinfo_t devinfo;
|
||||
} event_data_t;
|
||||
|
||||
typedef struct dive_data_t {
|
||||
dc_device_t *device;
|
||||
dc_buffer_t **fingerprint;
|
||||
unsigned int number;
|
||||
dctool_output_t *output;
|
||||
} dive_data_t;
|
||||
|
||||
static int
|
||||
dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata)
|
||||
{
|
||||
dive_data_t *divedata = (dive_data_t *) userdata;
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_parser_t *parser = NULL;
|
||||
|
||||
divedata->number++;
|
||||
|
||||
message ("Dive: number=%u, size=%u, fingerprint=", divedata->number, size);
|
||||
for (unsigned int i = 0; i < fsize; ++i)
|
||||
message ("%02X", fingerprint[i]);
|
||||
message ("\n");
|
||||
|
||||
// Keep a copy of the most recent fingerprint. Because dives are
|
||||
// guaranteed to be downloaded in reverse order, the most recent
|
||||
// dive is always the first dive.
|
||||
if (divedata->number == 1) {
|
||||
dc_buffer_t *fp = dc_buffer_new (fsize);
|
||||
dc_buffer_append (fp, fingerprint, fsize);
|
||||
*divedata->fingerprint = fp;
|
||||
}
|
||||
|
||||
// Create the parser.
|
||||
message ("Creating the parser.\n");
|
||||
rc = dc_parser_new (&parser, divedata->device, data, size);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error creating the parser.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Parse the dive data.
|
||||
message ("Parsing the dive data.\n");
|
||||
rc = dctool_output_write (divedata->output, parser, data, size, fingerprint, fsize);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error parsing the dive data.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_parser_destroy (parser);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
|
||||
{
|
||||
const dc_event_devinfo_t *devinfo = (const dc_event_devinfo_t *) data;
|
||||
|
||||
event_data_t *eventdata = (event_data_t *) userdata;
|
||||
|
||||
// Forward to the default event handler.
|
||||
dctool_event_cb (device, event, data, userdata);
|
||||
|
||||
switch (event) {
|
||||
case DC_EVENT_DEVINFO:
|
||||
// Load the fingerprint from the cache. If there is no
|
||||
// fingerprint present in the cache, a NULL buffer is returned,
|
||||
// and the registered fingerprint will be cleared.
|
||||
if (eventdata->cachedir) {
|
||||
char filename[1024] = {0};
|
||||
dc_family_t family = DC_FAMILY_NULL;
|
||||
dc_buffer_t *fingerprint = NULL;
|
||||
|
||||
// Generate the fingerprint filename.
|
||||
family = dc_device_get_type (device);
|
||||
snprintf (filename, sizeof (filename), "%s/%s-%08X.bin",
|
||||
eventdata->cachedir, dctool_family_name (family), devinfo->serial);
|
||||
|
||||
// Read the fingerprint file.
|
||||
fingerprint = dctool_file_read (filename);
|
||||
|
||||
// Register the fingerprint data.
|
||||
dc_device_set_fingerprint (device,
|
||||
dc_buffer_get_data (fingerprint),
|
||||
dc_buffer_get_size (fingerprint));
|
||||
|
||||
// Free the buffer again.
|
||||
dc_buffer_free (fingerprint);
|
||||
}
|
||||
|
||||
// Keep a copy of the event data. It will be used for generating
|
||||
// the fingerprint filename again after a (successful) download.
|
||||
eventdata->devinfo = *devinfo;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = NULL;
|
||||
dc_device_t *device = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Initialize the event data.
|
||||
event_data_t eventdata = {0};
|
||||
if (fingerprint) {
|
||||
eventdata.cachedir = NULL;
|
||||
} else {
|
||||
eventdata.cachedir = cachedir;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, event_cb, &eventdata);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the fingerprint data.
|
||||
if (fingerprint) {
|
||||
message ("Registering the fingerprint data.\n");
|
||||
rc = dc_device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint));
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the fingerprint data.");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize the dive data.
|
||||
dive_data_t divedata = {0};
|
||||
divedata.device = device;
|
||||
divedata.fingerprint = &ofingerprint;
|
||||
divedata.number = 0;
|
||||
divedata.output = output;
|
||||
|
||||
// Download the dives.
|
||||
message ("Downloading the dives.\n");
|
||||
rc = dc_device_foreach (device, dive_cb, &divedata);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error downloading the dives.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Store the fingerprint data.
|
||||
if (cachedir && ofingerprint) {
|
||||
char filename[1024] = {0};
|
||||
dc_family_t family = DC_FAMILY_NULL;
|
||||
|
||||
// Generate the fingerprint filename.
|
||||
family = dc_device_get_type (device);
|
||||
snprintf (filename, sizeof (filename), "%s/%s-%08X.bin",
|
||||
cachedir, dctool_family_name (family), eventdata.devinfo.serial);
|
||||
|
||||
// Write the fingerprint file.
|
||||
dctool_file_write (filename, ofingerprint);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_buffer_free (ofingerprint);
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_download_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_buffer_t *fingerprint = NULL;
|
||||
dctool_output_t *output = NULL;
|
||||
dctool_units_t units = DCTOOL_UNITS_METRIC;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *fphex = NULL;
|
||||
const char *filename = NULL;
|
||||
const char *cachedir = NULL;
|
||||
const char *format = "xml";
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ht:o:p:c:f:u:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"transport", required_argument, 0, 't'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"fingerprint", required_argument, 0, 'p'},
|
||||
{"cache", required_argument, 0, 'c'},
|
||||
{"format", required_argument, 0, 'f'},
|
||||
{"units", required_argument, 0, 'u'},
|
||||
{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;
|
||||
case 'o':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
fphex = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
cachedir = optarg;
|
||||
break;
|
||||
case 'f':
|
||||
format = optarg;
|
||||
break;
|
||||
case 'u':
|
||||
if (strcmp (optarg, "metric") == 0)
|
||||
units = DCTOOL_UNITS_METRIC;
|
||||
if (strcmp (optarg, "imperial") == 0)
|
||||
units = DCTOOL_UNITS_IMPERIAL;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_download);
|
||||
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.
|
||||
fingerprint = dctool_convert_hex2bin (fphex);
|
||||
|
||||
// Create the output.
|
||||
if (strcasecmp(format, "raw") == 0) {
|
||||
output = dctool_raw_output_new (filename);
|
||||
} else if (strcasecmp(format, "xml") == 0) {
|
||||
output = dctool_xml_output_new (filename, units);
|
||||
} else {
|
||||
message ("Unknown output format: %s\n", format);
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
if (output == NULL) {
|
||||
message ("Failed to create the output.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Download the dives.
|
||||
status = download (context, descriptor, transport, argv[0], cachedir, fingerprint, output);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
message ("ERROR: %s\n", dctool_errmsg (status));
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dctool_output_free (output);
|
||||
dc_buffer_free (fingerprint);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_download = {
|
||||
dctool_download_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"download",
|
||||
"Download the dives",
|
||||
"Usage:\n"
|
||||
" dctool download [options] <devname>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -t, --transport <name> Transport type\n"
|
||||
" -o, --output <filename> Output filename\n"
|
||||
" -p, --fingerprint <data> Fingerprint data (hexadecimal)\n"
|
||||
" -c, --cache <directory> Cache directory\n"
|
||||
" -f, --format <format> Output format\n"
|
||||
" -u, --units <units> Set units (metric or imperial)\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -t <transport> Transport type\n"
|
||||
" -o <filename> Output filename\n"
|
||||
" -p <fingerprint> Fingerprint data (hexadecimal)\n"
|
||||
" -c <directory> Cache directory\n"
|
||||
" -f <format> Output format\n"
|
||||
" -u <units> Set units (metric or imperial)\n"
|
||||
#endif
|
||||
"\n"
|
||||
"Supported output formats:\n"
|
||||
"\n"
|
||||
" XML (default)\n"
|
||||
"\n"
|
||||
" All dives are exported to a single xml file.\n"
|
||||
"\n"
|
||||
" RAW\n"
|
||||
"\n"
|
||||
" Each dive is exported to a raw (binary) file. To output multiple\n"
|
||||
" files, the filename is interpreted as a template and should\n"
|
||||
" contain one or more placeholders.\n"
|
||||
"\n"
|
||||
"Supported template placeholders:\n"
|
||||
"\n"
|
||||
" %f Fingerprint (hexadecimal format)\n"
|
||||
" %n Number (4 digits)\n"
|
||||
" %t Timestamp (basic ISO 8601 date/time format)\n"
|
||||
};
|
||||
@ -1,218 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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>
|
||||
#include <string.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/device.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
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)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, dctool_event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the fingerprint data.
|
||||
if (fingerprint) {
|
||||
message ("Registering the fingerprint data.\n");
|
||||
rc = dc_device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint));
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the fingerprint data.");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
// Download the memory dump.
|
||||
message ("Downloading the memory dump.\n");
|
||||
rc = dc_device_dump (device, buffer);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error downloading the memory dump.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_dump_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_buffer_t *fingerprint = NULL;
|
||||
dc_buffer_t *buffer = NULL;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *fphex = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ht:o:p:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"transport", required_argument, 0, 't'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"fingerprint", required_argument, 0, 'p'},
|
||||
{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;
|
||||
case 'o':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
fphex = optarg;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_dump);
|
||||
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.
|
||||
fingerprint = dctool_convert_hex2bin (fphex);
|
||||
|
||||
// Allocate a memory buffer.
|
||||
buffer = dc_buffer_new (0);
|
||||
|
||||
// Download the memory dump.
|
||||
status = dump (context, descriptor, transport, argv[0], fingerprint, buffer);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
message ("ERROR: %s\n", dctool_errmsg (status));
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Write the memory dump to disk.
|
||||
dctool_file_write (filename, buffer);
|
||||
|
||||
cleanup:
|
||||
dc_buffer_free (buffer);
|
||||
dc_buffer_free (fingerprint);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_dump = {
|
||||
dctool_dump_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"dump",
|
||||
"Download a memory dump",
|
||||
"Usage:\n"
|
||||
" dctool dump [options] <devname>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -t, --transport <name> Transport type\n"
|
||||
" -o, --output <filename> Output filename\n"
|
||||
" -p, --fingerprint <data> Fingerprint data (hexadecimal)\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -t <transport> Transport type\n"
|
||||
" -o <filename> Output filename\n"
|
||||
" -p <fingerprint> Fingerprint data (hexadecimal)\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,210 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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/device.h>
|
||||
#include <libdivecomputer/hw_ostc.h>
|
||||
#include <libdivecomputer/hw_ostc3.h>
|
||||
#include <libdivecomputer/divesystem_idive.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
static dc_status_t
|
||||
fwupdate (dc_context_t *context, dc_descriptor_t *descriptor, dc_transport_t transport, const char *devname, const char *hexfile)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_PROGRESS;
|
||||
rc = dc_device_set_events (device, events, dctool_event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Update the firmware.
|
||||
message ("Updating the firmware.\n");
|
||||
switch (dc_device_get_type (device)) {
|
||||
case DC_FAMILY_HW_OSTC:
|
||||
rc = hw_ostc_device_fwupdate (device, hexfile);
|
||||
break;
|
||||
case DC_FAMILY_HW_OSTC3:
|
||||
rc = hw_ostc3_device_fwupdate (device, hexfile, false);
|
||||
break;
|
||||
case DC_FAMILY_DIVESYSTEM_IDIVE:
|
||||
rc = divesystem_idive_device_fwupdate (device, hexfile);
|
||||
break;
|
||||
default:
|
||||
rc = DC_STATUS_UNSUPPORTED;
|
||||
break;
|
||||
}
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error updating the firmware.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_fwupdate_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *filename = NULL;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ht:f:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"transport", required_argument, 0, 't'},
|
||||
{"firmware", required_argument, 0, 'f'},
|
||||
{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 'f':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 't':
|
||||
transport = dctool_transport_type (optarg);
|
||||
break;
|
||||
case 'h':
|
||||
help = 1;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_fwupdate);
|
||||
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.
|
||||
if (!filename) {
|
||||
message ("No firmware file specified.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Update the firmware.
|
||||
status = fwupdate (context, descriptor, transport, argv[0], filename);
|
||||
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_fwupdate = {
|
||||
dctool_fwupdate_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"fwupdate",
|
||||
"Update the firmware",
|
||||
"Usage:\n"
|
||||
" dctool fwupdate [options]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -t, --transport <name> Transport type\n"
|
||||
" -f, --firmware <filename> Firmware filename\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -t <transport> Transport type\n"
|
||||
" -f <filename> Firmware filename\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,107 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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 "dctool.h"
|
||||
#include "utils.h"
|
||||
|
||||
static int
|
||||
dctool_help_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "h";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{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;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_help);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Try to find the command.
|
||||
const dctool_command_t *command = NULL;
|
||||
if (argv[0] != NULL) {
|
||||
command = dctool_command_find (argv[0]);
|
||||
if (command == NULL) {
|
||||
message ("Unknown command %s.\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// Show help message for the command.
|
||||
dctool_command_showhelp (command);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_help = {
|
||||
dctool_help_run,
|
||||
DCTOOL_CONFIG_NONE,
|
||||
"help",
|
||||
"Show basic help instructions",
|
||||
"Usage:\n"
|
||||
" dctool help [options] [<command>]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,105 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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 "dctool.h"
|
||||
|
||||
static int
|
||||
dctool_list_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *dummy)
|
||||
{
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "h";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{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;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_list);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
dc_iterator_t *iterator = NULL;
|
||||
dc_descriptor_t *descriptor = NULL;
|
||||
dc_descriptor_iterator (&iterator);
|
||||
while (dc_iterator_next (iterator, &descriptor) == DC_STATUS_SUCCESS) {
|
||||
printf ("%s %s\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
dc_descriptor_free (descriptor);
|
||||
}
|
||||
dc_iterator_free (iterator);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_list = {
|
||||
dctool_list_run,
|
||||
DCTOOL_CONFIG_NONE,
|
||||
"list",
|
||||
"List supported devices",
|
||||
"Usage:\n"
|
||||
" dctool list [options]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,207 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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>
|
||||
#include <string.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/parser.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "output.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
#define REACTPROWHITE 0x4354
|
||||
|
||||
static dc_status_t
|
||||
parse (dc_buffer_t *buffer, dc_context_t *context, dc_descriptor_t *descriptor, unsigned int devtime, dc_ticks_t systime, dctool_output_t *output)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_parser_t *parser = NULL;
|
||||
unsigned char *data = dc_buffer_get_data (buffer);
|
||||
unsigned int size = dc_buffer_get_size (buffer);
|
||||
|
||||
// Create the parser.
|
||||
message ("Creating the parser.\n");
|
||||
rc = dc_parser_new2 (&parser, context, descriptor, data, size);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error creating the parser.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Set the clock.
|
||||
message ("Setting the clock.\n");
|
||||
rc = dc_parser_set_clock (parser, devtime, systime);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error setting the clock.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Parse the dive data.
|
||||
message ("Parsing the dive data.\n");
|
||||
rc = dctool_output_write (output, parser, data, size, NULL, 0);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error parsing the dive data.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_parse_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
// Default values.
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_buffer_t *buffer = NULL;
|
||||
dctool_output_t *output = NULL;
|
||||
dctool_units_t units = DCTOOL_UNITS_METRIC;
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *filename = NULL;
|
||||
unsigned int devtime = 0;
|
||||
dc_ticks_t systime = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ho:d:s:u:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{"devtime", required_argument, 0, 'd'},
|
||||
{"systime", required_argument, 0, 's'},
|
||||
{"units", required_argument, 0, 'u'},
|
||||
{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 'o':
|
||||
filename = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
devtime = strtoul (optarg, NULL, 0);
|
||||
break;
|
||||
case 's':
|
||||
systime = strtoll (optarg, NULL, 0);
|
||||
break;
|
||||
case 'u':
|
||||
if (strcmp (optarg, "metric") == 0)
|
||||
units = DCTOOL_UNITS_METRIC;
|
||||
if (strcmp (optarg, "imperial") == 0)
|
||||
units = DCTOOL_UNITS_IMPERIAL;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_parse);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Create the output.
|
||||
output = dctool_xml_output_new (filename, units);
|
||||
if (output == NULL) {
|
||||
message ("Failed to create the output.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (int i = 0; i < argc; ++i) {
|
||||
// Read the input file.
|
||||
buffer = dctool_file_read (argv[i]);
|
||||
if (buffer == NULL) {
|
||||
message ("Failed to open the input file.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Parse the dive.
|
||||
status = parse (buffer, context, descriptor, devtime, systime, output);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
message ("ERROR: %s\n", dctool_errmsg (status));
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
dc_buffer_free (buffer);
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_buffer_free (buffer);
|
||||
dctool_output_free (output);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_parse = {
|
||||
dctool_parse_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"parse",
|
||||
"Parse previously downloaded dives",
|
||||
"Usage:\n"
|
||||
" dctool parse [options] <filename>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -o, --output <filename> Output filename\n"
|
||||
" -d, --devtime <timestamp> Device time\n"
|
||||
" -s, --systime <timestamp> System time\n"
|
||||
" -u, --units <units> Set units (metric or imperial)\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -o <filename> Output filename\n"
|
||||
" -d <devtime> Device time\n"
|
||||
" -s <systime> System time\n"
|
||||
" -u <units> Set units (metric or imperial)\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,224 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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/device.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
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)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, dctool_event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Read data from the internal memory.
|
||||
message ("Reading data from the internal memory.\n");
|
||||
rc = dc_device_read (device, address, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer));
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error reading from the internal memory.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_read_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_buffer_t *buffer = NULL;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *filename = NULL;
|
||||
unsigned int address = 0, have_address = 0;
|
||||
unsigned int count = 0, have_count = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ht:a:c:o:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"transport", required_argument, 0, 't'},
|
||||
{"address", required_argument, 0, 'a'},
|
||||
{"count", required_argument, 0, 'c'},
|
||||
{"output", required_argument, 0, 'o'},
|
||||
{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;
|
||||
case 'a':
|
||||
address = strtoul (optarg, NULL, 0);
|
||||
have_address = 1;
|
||||
break;
|
||||
case 'c':
|
||||
count = strtoul (optarg, NULL, 0);
|
||||
have_count = 1;
|
||||
break;
|
||||
case 'o':
|
||||
filename = optarg;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_read);
|
||||
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.
|
||||
if (!have_address || !have_count) {
|
||||
message ("No memory address or byte count specified.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Allocate a memory buffer.
|
||||
buffer = dc_buffer_new (count);
|
||||
dc_buffer_resize (buffer, count);
|
||||
if (buffer == NULL) {
|
||||
message ("Failed to allocate a memory buffer.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Read data from the internal memory.
|
||||
status = doread (context, descriptor, transport, argv[0], address, buffer);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
message ("ERROR: %s\n", dctool_errmsg (status));
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Write the buffer to file.
|
||||
dctool_file_write (filename, buffer);
|
||||
|
||||
cleanup:
|
||||
dc_buffer_free (buffer);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_read = {
|
||||
dctool_read_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"read",
|
||||
"Read data from the internal memory",
|
||||
"Usage:\n"
|
||||
" dctool read [options] <devname>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -t, --transport <name> Transport type\n"
|
||||
" -a, --address <address> Memory address\n"
|
||||
" -c, --count <count> Number of bytes\n"
|
||||
" -o, --output <filename> Output filename\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -t <transport> Transport type\n"
|
||||
" -a <address> Memory address\n"
|
||||
" -c <count> Number of bytes\n"
|
||||
" -o <filename> Output filename\n"
|
||||
#endif
|
||||
};
|
||||
@ -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
|
||||
};
|
||||
@ -1,189 +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/device.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
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)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, dctool_event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Syncronize the device clock.
|
||||
message ("Syncronize the device clock.\n");
|
||||
rc = dc_device_timesync (device, datetime);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error syncronizing the device clock.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_timesync_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
|
||||
// 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_timesync);
|
||||
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.
|
||||
dc_datetime_t datetime = {0};
|
||||
dc_ticks_t now = dc_datetime_now ();
|
||||
if (!dc_datetime_localtime(&datetime, now)) {
|
||||
message ("ERROR: Failed to get the system time.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Synchronize the device clock.
|
||||
status = do_timesync (context, descriptor, transport, argv[0], &datetime);
|
||||
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_timesync = {
|
||||
dctool_timesync_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"timesync",
|
||||
"Synchronize the device clock",
|
||||
"Usage:\n"
|
||||
" dctool timesync [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
|
||||
};
|
||||
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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/version.h>
|
||||
|
||||
#include "dctool.h"
|
||||
|
||||
static int
|
||||
dctool_version_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "h";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{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;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_version);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
printf ("libdivecomputer version %s\n", dc_version (NULL));
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_version = {
|
||||
dctool_version_run,
|
||||
DCTOOL_CONFIG_NONE,
|
||||
"version",
|
||||
"Show version information",
|
||||
"Usage:\n"
|
||||
" dctool version [options]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
#endif
|
||||
};
|
||||
@ -1,227 +0,0 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 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/device.h>
|
||||
|
||||
#include "dctool.h"
|
||||
#include "common.h"
|
||||
#include "utils.h"
|
||||
|
||||
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)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_iostream_t *iostream = 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.
|
||||
message ("Opening the device (%s %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
rc = dc_device_open (&device, context, descriptor, iostream);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error opening the device.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, dctool_event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the event handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, dctool_cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error registering the cancellation handler.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Write data to the internal memory.
|
||||
message ("Writing data to the internal memory.\n");
|
||||
rc = dc_device_write (device, address, dc_buffer_get_data (buffer), dc_buffer_get_size (buffer));
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error writing to the internal memory.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_device_close (device);
|
||||
dc_iostream_close (iostream);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int
|
||||
dctool_write_run (int argc, char *argv[], dc_context_t *context, dc_descriptor_t *descriptor)
|
||||
{
|
||||
int exitcode = EXIT_SUCCESS;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
dc_buffer_t *buffer = NULL;
|
||||
dc_transport_t transport = dctool_transport_default (descriptor);
|
||||
|
||||
// Default option values.
|
||||
unsigned int help = 0;
|
||||
const char *filename = NULL;
|
||||
unsigned int address = 0, have_address = 0;
|
||||
unsigned int count = 0, have_count = 0;
|
||||
|
||||
// Parse the command-line options.
|
||||
int opt = 0;
|
||||
const char *optstring = "ht:a:c:i:";
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
struct option options[] = {
|
||||
{"help", no_argument, 0, 'h'},
|
||||
{"transport", required_argument, 0, 't'},
|
||||
{"address", required_argument, 0, 'a'},
|
||||
{"count", required_argument, 0, 'c'},
|
||||
{"input", required_argument, 0, 'i'},
|
||||
{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;
|
||||
case 'a':
|
||||
address = strtoul (optarg, NULL, 0);
|
||||
have_address = 1;
|
||||
break;
|
||||
case 'c':
|
||||
count = strtoul (optarg, NULL, 0);
|
||||
have_count = 1;
|
||||
break;
|
||||
case 'i':
|
||||
filename = optarg;
|
||||
break;
|
||||
default:
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
// Show help message.
|
||||
if (help) {
|
||||
dctool_command_showhelp (&dctool_write);
|
||||
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.
|
||||
if (!have_address) {
|
||||
message ("No memory address specified.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Read the buffer from file.
|
||||
buffer = dctool_file_read (filename);
|
||||
if (buffer == NULL) {
|
||||
message ("Failed to read the input file.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Check the number of bytes (if provided)
|
||||
if (have_count && count != dc_buffer_get_size (buffer)) {
|
||||
message ("Number of bytes doesn't match file length.\n");
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Write data to the internal memory.
|
||||
status = dowrite (context, descriptor, transport, argv[0], address, buffer);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
message ("ERROR: %s\n", dctool_errmsg (status));
|
||||
exitcode = EXIT_FAILURE;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
dc_buffer_free (buffer);
|
||||
return exitcode;
|
||||
}
|
||||
|
||||
const dctool_command_t dctool_write = {
|
||||
dctool_write_run,
|
||||
DCTOOL_CONFIG_DESCRIPTOR,
|
||||
"write",
|
||||
"Write data to the internal memory",
|
||||
"Usage:\n"
|
||||
" dctool write [options] <devname>\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
#ifdef HAVE_GETOPT_LONG
|
||||
" -h, --help Show help message\n"
|
||||
" -t, --transport <name> Transport type\n"
|
||||
" -a, --address <address> Memory address\n"
|
||||
" -c, --count <count> Number of bytes\n"
|
||||
" -i, --input <filename> Input filename\n"
|
||||
#else
|
||||
" -h Show help message\n"
|
||||
" -t <transport> Transport type\n"
|
||||
" -a <address> Memory address\n"
|
||||
" -c <count> Number of bytes\n"
|
||||
" -i <filename> Input filename\n"
|
||||
#endif
|
||||
};
|
||||
145
examples/hw_ostc_fwupdate.c
Normal file
145
examples/hw_ostc_fwupdate.c
Normal file
@ -0,0 +1,145 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <libdivecomputer/hw_ostc.h>
|
||||
#include <libdivecomputer/hw_ostc3.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
|
||||
static void
|
||||
event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
|
||||
{
|
||||
const dc_event_progress_t *progress = (dc_event_progress_t *) data;
|
||||
|
||||
switch (event) {
|
||||
case DC_EVENT_PROGRESS:
|
||||
message ("Event: progress %3.2f%% (%u/%u)\n",
|
||||
100.0 * (double) progress->current / (double) progress->maximum,
|
||||
progress->current, progress->maximum);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
fwupdate (const char *name, const char *hexfile, int ostc3)
|
||||
{
|
||||
dc_context_t *context = NULL;
|
||||
dc_device_t *device = NULL;
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
|
||||
dc_context_new (&context);
|
||||
dc_context_set_loglevel (context, DC_LOGLEVEL_ALL);
|
||||
dc_context_set_logfunc (context, logfunc, NULL);
|
||||
|
||||
if (ostc3) {
|
||||
message ("hw_ostc3_device_open\n");
|
||||
rc = hw_ostc3_device_open (&device, context, name);
|
||||
} else {
|
||||
message ("hw_ostc_device_open\n");
|
||||
rc = hw_ostc_device_open (&device, context, name);
|
||||
}
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error opening serial port.");
|
||||
dc_context_free (context);
|
||||
return rc;
|
||||
}
|
||||
|
||||
message ("dc_device_set_events.\n");
|
||||
rc = dc_device_set_events (device, DC_EVENT_PROGRESS, event_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error registering the event handler.");
|
||||
dc_device_close (device);
|
||||
dc_context_free (context);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (ostc3) {
|
||||
message ("hw_ostc3_device_fwupdate\n");
|
||||
rc = hw_ostc3_device_fwupdate (device, hexfile);
|
||||
} else {
|
||||
message ("hw_ostc_device_fwupdate\n");
|
||||
rc = hw_ostc_device_fwupdate (device, hexfile);
|
||||
}
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error flashing firmware.");
|
||||
dc_device_close (device);
|
||||
dc_context_free (context);
|
||||
return rc;
|
||||
}
|
||||
|
||||
message ("dc_device_close\n");
|
||||
rc = dc_device_close (device);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Cannot close device.");
|
||||
dc_context_free (context);
|
||||
return rc;
|
||||
}
|
||||
|
||||
dc_context_free (context);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
message_set_logfile ("OSTC-FWUPDATE.LOG");
|
||||
|
||||
#ifdef _WIN32
|
||||
const char* name = "COM1";
|
||||
#else
|
||||
const char* name = "/dev/ttyUSB0";
|
||||
#endif
|
||||
const char *hexfile = NULL;
|
||||
int ostc3 = 0;
|
||||
|
||||
if (argc > 1) {
|
||||
name = argv[1];
|
||||
}
|
||||
if (argc > 2) {
|
||||
hexfile = argv[2];
|
||||
}
|
||||
if (argc > 3) {
|
||||
if (strcmp(argv[3], "-3") == 0) {
|
||||
ostc3 = 1;
|
||||
} else {
|
||||
ostc3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
message ("DEVICE=%s\n", name);
|
||||
message ("HEXFILE=%s\n", hexfile);
|
||||
|
||||
dc_status_t a = fwupdate (name, hexfile, ostc3);
|
||||
|
||||
message ("SUMMARY\n");
|
||||
message ("-------\n");
|
||||
message ("fwupdate: %s\n", errmsg (a));
|
||||
|
||||
message_set_logfile (NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,58 +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 DCTOOL_OUTPUT_PRIVATE_H
|
||||
#define DCTOOL_OUTPUT_PRIVATE_H
|
||||
|
||||
#include <libdivecomputer/common.h>
|
||||
#include <libdivecomputer/parser.h>
|
||||
|
||||
#include "output.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct dctool_output_vtable_t dctool_output_vtable_t;
|
||||
|
||||
struct dctool_output_t {
|
||||
const dctool_output_vtable_t *vtable;
|
||||
unsigned int number;
|
||||
};
|
||||
|
||||
struct dctool_output_vtable_t {
|
||||
size_t size;
|
||||
|
||||
dc_status_t (*write) (dctool_output_t *output, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize);
|
||||
|
||||
dc_status_t (*free) (dctool_output_t *output);
|
||||
};
|
||||
|
||||
dctool_output_t *
|
||||
dctool_output_allocate (const dctool_output_vtable_t *vtable);
|
||||
|
||||
void
|
||||
dctool_output_deallocate (dctool_output_t *output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DCTOOL_OUTPUT_PRIVATE_H */
|
||||
@ -1,79 +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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "output-private.h"
|
||||
|
||||
dctool_output_t *
|
||||
dctool_output_allocate (const dctool_output_vtable_t *vtable)
|
||||
{
|
||||
dctool_output_t *output = NULL;
|
||||
|
||||
assert(vtable != NULL);
|
||||
assert(vtable->size >= sizeof(dctool_output_t));
|
||||
|
||||
// Allocate memory.
|
||||
output = (dctool_output_t *) malloc (vtable->size);
|
||||
if (output == NULL) {
|
||||
return output;
|
||||
}
|
||||
|
||||
output->vtable = vtable;
|
||||
output->number = 0;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
void
|
||||
dctool_output_deallocate (dctool_output_t *output)
|
||||
{
|
||||
free (output);
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dctool_output_write (dctool_output_t *output, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize)
|
||||
{
|
||||
if (output == NULL || output->vtable->write == NULL)
|
||||
return DC_STATUS_SUCCESS;
|
||||
|
||||
output->number++;
|
||||
|
||||
return output->vtable->write (output, parser, data, size, fingerprint, fsize);
|
||||
}
|
||||
|
||||
dc_status_t
|
||||
dctool_output_free (dctool_output_t *output)
|
||||
{
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
|
||||
if (output == NULL)
|
||||
return DC_STATUS_SUCCESS;
|
||||
|
||||
if (output->vtable->free) {
|
||||
status = output->vtable->free (output);
|
||||
}
|
||||
|
||||
dctool_output_deallocate (output);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -1,54 +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 DCTOOL_OUTPUT_H
|
||||
#define DCTOOL_OUTPUT_H
|
||||
|
||||
#include <libdivecomputer/common.h>
|
||||
#include <libdivecomputer/parser.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct dctool_output_t dctool_output_t;
|
||||
|
||||
typedef enum dctool_units_t {
|
||||
DCTOOL_UNITS_METRIC,
|
||||
DCTOOL_UNITS_IMPERIAL
|
||||
} dctool_units_t;
|
||||
|
||||
dctool_output_t *
|
||||
dctool_xml_output_new (const char *filename, dctool_units_t units);
|
||||
|
||||
dctool_output_t *
|
||||
dctool_raw_output_new (const char *template);
|
||||
|
||||
dc_status_t
|
||||
dctool_output_write (dctool_output_t *output, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize);
|
||||
|
||||
dc_status_t
|
||||
dctool_output_free (dctool_output_t *output);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DCTOOL_OUTPUT_H */
|
||||
@ -1,219 +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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "output-private.h"
|
||||
#include "utils.h"
|
||||
|
||||
static dc_status_t dctool_raw_output_write (dctool_output_t *output, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize);
|
||||
static dc_status_t dctool_raw_output_free (dctool_output_t *output);
|
||||
|
||||
typedef struct dctool_raw_output_t {
|
||||
dctool_output_t base;
|
||||
char *template;
|
||||
} dctool_raw_output_t;
|
||||
|
||||
static const dctool_output_vtable_t raw_vtable = {
|
||||
sizeof(dctool_raw_output_t), /* size */
|
||||
dctool_raw_output_write, /* write */
|
||||
dctool_raw_output_free, /* free */
|
||||
};
|
||||
|
||||
static int
|
||||
mktemplate_fingerprint (char *buffer, size_t size, const unsigned char fingerprint[], size_t fsize)
|
||||
{
|
||||
const unsigned char ascii[] = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
if (size < 2 * fsize + 1)
|
||||
return -1;
|
||||
|
||||
for (size_t i = 0; i < fsize; ++i) {
|
||||
// Set the most-significant nibble.
|
||||
unsigned char msn = (fingerprint[i] >> 4) & 0x0F;
|
||||
buffer[i * 2 + 0] = ascii[msn];
|
||||
|
||||
// Set the least-significant nibble.
|
||||
unsigned char lsn = fingerprint[i] & 0x0F;
|
||||
buffer[i * 2 + 1] = ascii[lsn];
|
||||
}
|
||||
|
||||
// Null-terminate the string.
|
||||
buffer[fsize * 2] = 0;
|
||||
|
||||
return fsize * 2;
|
||||
}
|
||||
|
||||
static int
|
||||
mktemplate_datetime (char *buffer, size_t size, dc_parser_t *parser)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
dc_datetime_t datetime = {0};
|
||||
int n = 0;
|
||||
|
||||
rc = dc_parser_get_datetime (parser, &datetime);
|
||||
if (rc != DC_STATUS_SUCCESS)
|
||||
return -1;
|
||||
|
||||
n = snprintf (buffer, size, "%04i%02i%02iT%02i%02i%02i",
|
||||
datetime.year, datetime.month, datetime.day,
|
||||
datetime.hour, datetime.minute, datetime.second);
|
||||
if (n < 0 || (size_t) n >= size)
|
||||
return -1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int
|
||||
mktemplate_number (char *buffer, size_t size, unsigned int number)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
n = snprintf (buffer, size, "%04u", number);
|
||||
if (n < 0 || (size_t) n >= size)
|
||||
return -1;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int
|
||||
mktemplate (char *buffer, size_t size, const char *format, dc_parser_t *parser, const unsigned char fingerprint[], size_t fsize, unsigned int number)
|
||||
{
|
||||
const char *p = format;
|
||||
size_t n = 0;
|
||||
int len = 0;
|
||||
char ch = 0;
|
||||
|
||||
while ((ch = *p++) != 0) {
|
||||
if (ch != '%') {
|
||||
if (n >= size)
|
||||
return -1;
|
||||
buffer[n] = ch;
|
||||
n++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ch = *p++;
|
||||
switch (ch) {
|
||||
case '%':
|
||||
if (n >= size)
|
||||
return -1;
|
||||
buffer[n] = ch;
|
||||
n++;
|
||||
break;
|
||||
case 't': // Timestamp
|
||||
len = mktemplate_datetime (buffer + n, size - n, parser);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
n += len;
|
||||
break;
|
||||
case 'f': // Fingerprint
|
||||
len = mktemplate_fingerprint (buffer + n, size - n, fingerprint, fsize);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
n += len;
|
||||
break;
|
||||
case 'n': // Number
|
||||
len = mktemplate_number (buffer + n, size - n, number);
|
||||
if (len < 0)
|
||||
return -1;
|
||||
n += len;
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Null-terminate the string
|
||||
if (n >= size)
|
||||
return -1;
|
||||
buffer[n] = 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
dctool_output_t *
|
||||
dctool_raw_output_new (const char *template)
|
||||
{
|
||||
dctool_raw_output_t *output = NULL;
|
||||
|
||||
if (template == NULL)
|
||||
goto error_exit;
|
||||
|
||||
// Allocate memory.
|
||||
output = (dctool_raw_output_t *) dctool_output_allocate (&raw_vtable);
|
||||
if (output == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
output->template = strdup(template);
|
||||
if (output->template == NULL) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
return (dctool_output_t *) output;
|
||||
|
||||
error_free:
|
||||
dctool_output_deallocate ((dctool_output_t *) output);
|
||||
error_exit:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
dctool_raw_output_write (dctool_output_t *abstract, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize)
|
||||
{
|
||||
dctool_raw_output_t *output = (dctool_raw_output_t *) abstract;
|
||||
|
||||
// Generate the filename.
|
||||
char name[1024] = {0};
|
||||
int ret = mktemplate (name, sizeof(name), output->template, parser, fingerprint, fsize, abstract->number);
|
||||
if (ret < 0) {
|
||||
ERROR("Failed to generate filename from template.");
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Open the output file.
|
||||
FILE *fp = fopen (name, "wb");
|
||||
if (fp == NULL) {
|
||||
ERROR("Failed to open the output file.");
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
// Write the data.
|
||||
fwrite (data, sizeof (unsigned char), size, fp);
|
||||
fclose (fp);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
dctool_raw_output_free (dctool_output_t *abstract)
|
||||
{
|
||||
dctool_raw_output_t *output = (dctool_raw_output_t *) abstract;
|
||||
|
||||
free (output->template);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
@ -1,522 +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
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <libdivecomputer/units.h>
|
||||
|
||||
#include "output-private.h"
|
||||
#include "utils.h"
|
||||
|
||||
static dc_status_t dctool_xml_output_write (dctool_output_t *output, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize);
|
||||
static dc_status_t dctool_xml_output_free (dctool_output_t *output);
|
||||
|
||||
typedef struct dctool_xml_output_t {
|
||||
dctool_output_t base;
|
||||
FILE *ostream;
|
||||
dctool_units_t units;
|
||||
} dctool_xml_output_t;
|
||||
|
||||
static const dctool_output_vtable_t xml_vtable = {
|
||||
sizeof(dctool_xml_output_t), /* size */
|
||||
dctool_xml_output_write, /* write */
|
||||
dctool_xml_output_free, /* free */
|
||||
};
|
||||
|
||||
typedef struct sample_data_t {
|
||||
FILE *ostream;
|
||||
dctool_units_t units;
|
||||
unsigned int nsamples;
|
||||
} sample_data_t;
|
||||
|
||||
static double
|
||||
convert_depth (double value, dctool_units_t units)
|
||||
{
|
||||
if (units == DCTOOL_UNITS_IMPERIAL) {
|
||||
return value / FEET;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
convert_temperature (double value, dctool_units_t units)
|
||||
{
|
||||
if (units == DCTOOL_UNITS_IMPERIAL) {
|
||||
return value * (9.0 / 5.0) + 32.0;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
convert_pressure (double value, dctool_units_t units)
|
||||
{
|
||||
if (units == DCTOOL_UNITS_IMPERIAL) {
|
||||
return value * BAR / PSI;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static double
|
||||
convert_volume (double value, dctool_units_t units)
|
||||
{
|
||||
if (units == DCTOOL_UNITS_IMPERIAL) {
|
||||
return value / 1000.0 / CUFT;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sample_cb (dc_sample_type_t type, const dc_sample_value_t *value, void *userdata)
|
||||
{
|
||||
static const char *events[] = {
|
||||
"none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter",
|
||||
"violation", "bookmark", "surface", "safety stop", "gaschange",
|
||||
"safety stop (voluntary)", "safety stop (mandatory)", "deepstop",
|
||||
"ceiling (safety stop)", "floor", "divetime", "maxdepth",
|
||||
"OLF", "PO2", "airtime", "rgbm", "heading", "tissue level warning",
|
||||
"gaschange2"};
|
||||
static const char *decostop[] = {
|
||||
"ndl", "safety", "deco", "deep"};
|
||||
|
||||
sample_data_t *sampledata = (sample_data_t *) userdata;
|
||||
|
||||
unsigned int seconds = 0, milliseconds = 0;
|
||||
|
||||
switch (type) {
|
||||
case DC_SAMPLE_TIME:
|
||||
seconds = value->time / 1000;
|
||||
milliseconds = value->time % 1000;
|
||||
if (sampledata->nsamples++)
|
||||
fprintf (sampledata->ostream, "</sample>\n");
|
||||
fprintf (sampledata->ostream, "<sample>\n");
|
||||
if (milliseconds) {
|
||||
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;
|
||||
case DC_SAMPLE_DEPTH:
|
||||
fprintf (sampledata->ostream, " <depth>%.2f</depth>\n",
|
||||
convert_depth(value->depth, sampledata->units));
|
||||
break;
|
||||
case DC_SAMPLE_PRESSURE:
|
||||
fprintf (sampledata->ostream, " <pressure tank=\"%u\">%.2f</pressure>\n",
|
||||
value->pressure.tank,
|
||||
convert_pressure(value->pressure.value, sampledata->units));
|
||||
break;
|
||||
case DC_SAMPLE_TEMPERATURE:
|
||||
fprintf (sampledata->ostream, " <temperature>%.2f</temperature>\n",
|
||||
convert_temperature(value->temperature, sampledata->units));
|
||||
break;
|
||||
case DC_SAMPLE_EVENT:
|
||||
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",
|
||||
value->event.type, value->event.time, value->event.flags, value->event.value, events[value->event.type]);
|
||||
}
|
||||
break;
|
||||
case DC_SAMPLE_RBT:
|
||||
fprintf (sampledata->ostream, " <rbt>%u</rbt>\n", value->rbt);
|
||||
break;
|
||||
case DC_SAMPLE_HEARTBEAT:
|
||||
fprintf (sampledata->ostream, " <heartbeat>%u</heartbeat>\n", value->heartbeat);
|
||||
break;
|
||||
case DC_SAMPLE_BEARING:
|
||||
fprintf (sampledata->ostream, " <bearing>%u</bearing>\n", value->bearing);
|
||||
break;
|
||||
case DC_SAMPLE_VENDOR:
|
||||
fprintf (sampledata->ostream, " <vendor type=\"%u\" size=\"%u\">", value->vendor.type, value->vendor.size);
|
||||
for (unsigned int i = 0; i < value->vendor.size; ++i)
|
||||
fprintf (sampledata->ostream, "%02X", ((const unsigned char *) value->vendor.data)[i]);
|
||||
fprintf (sampledata->ostream, "</vendor>\n");
|
||||
break;
|
||||
case DC_SAMPLE_SETPOINT:
|
||||
fprintf (sampledata->ostream, " <setpoint>%.2f</setpoint>\n", value->setpoint);
|
||||
break;
|
||||
case DC_SAMPLE_PPO2:
|
||||
if (value->ppo2.sensor != DC_SENSOR_NONE) {
|
||||
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;
|
||||
case DC_SAMPLE_CNS:
|
||||
fprintf (sampledata->ostream, " <cns>%.1f</cns>\n", value->cns * 100.0);
|
||||
break;
|
||||
case DC_SAMPLE_DECO:
|
||||
fprintf (sampledata->ostream, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n",
|
||||
value->deco.time,
|
||||
convert_depth(value->deco.depth, sampledata->units),
|
||||
decostop[value->deco.type]);
|
||||
if (value->deco.tts) {
|
||||
fprintf (sampledata->ostream, " <tts>%u</tts>\n",
|
||||
value->deco.tts);
|
||||
}
|
||||
break;
|
||||
case DC_SAMPLE_GASMIX:
|
||||
fprintf (sampledata->ostream, " <gasmix>%u</gasmix>\n", value->gasmix);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dctool_output_t *
|
||||
dctool_xml_output_new (const char *filename, dctool_units_t units)
|
||||
{
|
||||
dctool_xml_output_t *output = NULL;
|
||||
|
||||
if (filename == NULL)
|
||||
goto error_exit;
|
||||
|
||||
// Allocate memory.
|
||||
output = (dctool_xml_output_t *) dctool_output_allocate (&xml_vtable);
|
||||
if (output == NULL) {
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
// Open the output file.
|
||||
output->ostream = fopen (filename, "w");
|
||||
if (output->ostream == NULL) {
|
||||
goto error_free;
|
||||
}
|
||||
|
||||
output->units = units;
|
||||
|
||||
fprintf (output->ostream, "<device>\n");
|
||||
|
||||
return (dctool_output_t *) output;
|
||||
|
||||
error_free:
|
||||
dctool_output_deallocate ((dctool_output_t *) output);
|
||||
error_exit:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
dctool_xml_output_write (dctool_output_t *abstract, dc_parser_t *parser, const unsigned char data[], unsigned int size, const unsigned char fingerprint[], unsigned int fsize)
|
||||
{
|
||||
dctool_xml_output_t *output = (dctool_xml_output_t *) abstract;
|
||||
dc_status_t status = DC_STATUS_SUCCESS;
|
||||
|
||||
// Initialize the sample data.
|
||||
sample_data_t sampledata = {0};
|
||||
sampledata.nsamples = 0;
|
||||
sampledata.ostream = output->ostream;
|
||||
sampledata.units = output->units;
|
||||
|
||||
fprintf (output->ostream, "<dive>\n<number>%u</number>\n<size>%u</size>\n", abstract->number, size);
|
||||
|
||||
if (fingerprint) {
|
||||
fprintf (output->ostream, "<fingerprint>");
|
||||
for (unsigned int i = 0; i < fsize; ++i)
|
||||
fprintf (output->ostream, "%02X", fingerprint[i]);
|
||||
fprintf (output->ostream, "</fingerprint>\n");
|
||||
}
|
||||
|
||||
// Parse the datetime.
|
||||
message ("Parsing the datetime.\n");
|
||||
dc_datetime_t dt = {0};
|
||||
status = dc_parser_get_datetime (parser, &dt);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the datetime.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (dt.timezone == DC_TIMEZONE_NONE) {
|
||||
fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i</datetime>\n",
|
||||
dt.year, dt.month, dt.day,
|
||||
dt.hour, dt.minute, dt.second);
|
||||
} else {
|
||||
fprintf (output->ostream, "<datetime>%04i-%02i-%02i %02i:%02i:%02i %+03i:%02i</datetime>\n",
|
||||
dt.year, dt.month, dt.day,
|
||||
dt.hour, dt.minute, dt.second,
|
||||
dt.timezone / 3600, (abs(dt.timezone) % 3600) / 60);
|
||||
}
|
||||
|
||||
// Parse the divetime.
|
||||
message ("Parsing the divetime.\n");
|
||||
unsigned int divetime = 0;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the divetime.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf (output->ostream, "<divetime>%02u:%02u</divetime>\n",
|
||||
divetime / 60, divetime % 60);
|
||||
|
||||
// Parse the maxdepth.
|
||||
message ("Parsing the maxdepth.\n");
|
||||
double maxdepth = 0.0;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_MAXDEPTH, 0, &maxdepth);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the maxdepth.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf (output->ostream, "<maxdepth>%.2f</maxdepth>\n",
|
||||
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.
|
||||
message ("Parsing the temperature.\n");
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
dc_field_type_t fields[] = {DC_FIELD_TEMPERATURE_SURFACE,
|
||||
DC_FIELD_TEMPERATURE_MINIMUM,
|
||||
DC_FIELD_TEMPERATURE_MAXIMUM};
|
||||
const char *names[] = {"surface", "minimum", "maximum"};
|
||||
|
||||
double temperature = 0.0;
|
||||
status = dc_parser_get_field (parser, fields[i], 0, &temperature);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the temperature.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (status != DC_STATUS_UNSUPPORTED) {
|
||||
fprintf (output->ostream, "<temperature type=\"%s\">%.1f</temperature>\n",
|
||||
names[i],
|
||||
convert_temperature(temperature, output->units));
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the gas mixes.
|
||||
message ("Parsing the gas mixes.\n");
|
||||
unsigned int ngases = 0;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_GASMIX_COUNT, 0, &ngases);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the gas mix count.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ngases; ++i) {
|
||||
dc_gasmix_t gasmix = {0};
|
||||
status = dc_parser_get_field (parser, DC_FIELD_GASMIX, i, &gasmix);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the gas mix.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf (output->ostream,
|
||||
"<gasmix>\n"
|
||||
" <he>%.1f</he>\n"
|
||||
" <o2>%.1f</o2>\n"
|
||||
" <n2>%.1f</n2>\n",
|
||||
gasmix.helium * 100.0,
|
||||
gasmix.oxygen * 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.
|
||||
message ("Parsing the tanks.\n");
|
||||
unsigned int ntanks = 0;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the tank count.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ntanks; ++i) {
|
||||
const char *names[] = {"none", "metric", "imperial"};
|
||||
|
||||
dc_tank_t tank = {0};
|
||||
status = dc_parser_get_field (parser, DC_FIELD_TANK, i, &tank);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the tank.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
fprintf (output->ostream, "<tank>\n");
|
||||
if (tank.gasmix != DC_GASMIX_UNKNOWN) {
|
||||
fprintf (output->ostream,
|
||||
" <gasmix>%u</gasmix>\n",
|
||||
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) {
|
||||
fprintf (output->ostream,
|
||||
" <type>%s</type>\n"
|
||||
" <volume>%.1f</volume>\n"
|
||||
" <workpressure>%.2f</workpressure>\n",
|
||||
names[tank.type],
|
||||
convert_volume(tank.volume, output->units),
|
||||
convert_pressure(tank.workpressure, output->units));
|
||||
}
|
||||
fprintf (output->ostream,
|
||||
" <beginpressure>%.2f</beginpressure>\n"
|
||||
" <endpressure>%.2f</endpressure>\n"
|
||||
"</tank>\n",
|
||||
convert_pressure(tank.beginpressure, output->units),
|
||||
convert_pressure(tank.endpressure, output->units));
|
||||
}
|
||||
|
||||
// Parse the dive mode.
|
||||
message ("Parsing the dive mode.\n");
|
||||
dc_divemode_t divemode = DC_DIVEMODE_OC;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_DIVEMODE, 0, &divemode);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the dive mode.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (status != DC_STATUS_UNSUPPORTED) {
|
||||
const char *names[] = {"freedive", "gauge", "oc", "ccr", "scr"};
|
||||
fprintf (output->ostream, "<divemode>%s</divemode>\n",
|
||||
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.
|
||||
message ("Parsing the salinity.\n");
|
||||
dc_salinity_t salinity = {DC_WATER_FRESH, 0.0};
|
||||
status = dc_parser_get_field (parser, DC_FIELD_SALINITY, 0, &salinity);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the salinity.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (status != DC_STATUS_UNSUPPORTED) {
|
||||
const char *names[] = {"fresh", "salt"};
|
||||
if (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.
|
||||
message ("Parsing the atmospheric pressure.\n");
|
||||
double atmospheric = 0.0;
|
||||
status = dc_parser_get_field (parser, DC_FIELD_ATMOSPHERIC, 0, &atmospheric);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing the atmospheric pressure.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (status != DC_STATUS_UNSUPPORTED) {
|
||||
fprintf (output->ostream, "<atmospheric>%.5f</atmospheric>\n",
|
||||
convert_pressure(atmospheric, output->units));
|
||||
}
|
||||
|
||||
message ("Parsing strings.\n");
|
||||
int idx;
|
||||
for (idx = 0; idx < 100; idx++) {
|
||||
dc_field_string_t str = { NULL };
|
||||
status = dc_parser_get_field(parser, DC_FIELD_STRING, idx, &str);
|
||||
if (status != DC_STATUS_SUCCESS && status != DC_STATUS_UNSUPPORTED) {
|
||||
ERROR ("Error parsing strings");
|
||||
goto cleanup;
|
||||
}
|
||||
if (status == DC_STATUS_UNSUPPORTED)
|
||||
break;
|
||||
if (!str.desc || !str.value)
|
||||
break;
|
||||
fprintf (output->ostream, "<extradata key='%s' value='%s' />\n",
|
||||
str.desc, str.value);
|
||||
|
||||
}
|
||||
|
||||
// Parse the sample data.
|
||||
message ("Parsing the sample data.\n");
|
||||
status = dc_parser_samples_foreach (parser, sample_cb, &sampledata);
|
||||
if (status != DC_STATUS_SUCCESS) {
|
||||
ERROR ("Error parsing the sample data.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
||||
if (sampledata.nsamples)
|
||||
fprintf (output->ostream, "</sample>\n");
|
||||
fprintf (output->ostream, "</dive>\n");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static dc_status_t
|
||||
dctool_xml_output_free (dctool_output_t *abstract)
|
||||
{
|
||||
dctool_xml_output_t *output = (dctool_xml_output_t *) abstract;
|
||||
|
||||
fprintf (output->ostream, "</device>\n");
|
||||
|
||||
fclose (output->ostream);
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
980
examples/universal.c
Normal file
980
examples/universal.c
Normal file
@ -0,0 +1,980 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2009 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
|
||||
*/
|
||||
|
||||
#include <stdio.h> // fopen, fwrite, fclose
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define DC_TICKS_FORMAT "%I64d"
|
||||
#else
|
||||
#define DC_TICKS_FORMAT "%lld"
|
||||
#endif
|
||||
|
||||
#include <libdivecomputer/context.h>
|
||||
#include <libdivecomputer/device.h>
|
||||
#include <libdivecomputer/parser.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "common.h"
|
||||
|
||||
static const char *g_cachedir = NULL;
|
||||
static int g_cachedir_read = 1;
|
||||
|
||||
typedef struct device_data_t {
|
||||
dc_event_devinfo_t devinfo;
|
||||
dc_event_clock_t clock;
|
||||
} device_data_t;
|
||||
|
||||
typedef struct dive_data_t {
|
||||
dc_device_t *device;
|
||||
FILE* fp;
|
||||
unsigned int number;
|
||||
dc_buffer_t *fingerprint;
|
||||
} dive_data_t;
|
||||
|
||||
typedef struct sample_data_t {
|
||||
FILE* fp;
|
||||
unsigned int nsamples;
|
||||
} sample_data_t;
|
||||
|
||||
typedef struct backend_table_t {
|
||||
const char *name;
|
||||
dc_family_t type;
|
||||
} backend_table_t;
|
||||
|
||||
static const backend_table_t g_backends[] = {
|
||||
{"solution", DC_FAMILY_SUUNTO_SOLUTION},
|
||||
{"eon", DC_FAMILY_SUUNTO_EON},
|
||||
{"vyper", DC_FAMILY_SUUNTO_VYPER},
|
||||
{"vyper2", DC_FAMILY_SUUNTO_VYPER2},
|
||||
{"d9", DC_FAMILY_SUUNTO_D9},
|
||||
{"eonsteel", DC_FAMILY_SUUNTO_EONSTEEL},
|
||||
{"aladin", DC_FAMILY_UWATEC_ALADIN},
|
||||
{"memomouse", DC_FAMILY_UWATEC_MEMOMOUSE},
|
||||
{"smart", DC_FAMILY_UWATEC_SMART},
|
||||
{"meridian", DC_FAMILY_UWATEC_MERIDIAN},
|
||||
{"sensus", DC_FAMILY_REEFNET_SENSUS},
|
||||
{"sensuspro", DC_FAMILY_REEFNET_SENSUSPRO},
|
||||
{"sensusultra", DC_FAMILY_REEFNET_SENSUSULTRA},
|
||||
{"vtpro", DC_FAMILY_OCEANIC_VTPRO},
|
||||
{"veo250", DC_FAMILY_OCEANIC_VEO250},
|
||||
{"atom2", DC_FAMILY_OCEANIC_ATOM2},
|
||||
{"nemo", DC_FAMILY_MARES_NEMO},
|
||||
{"puck", DC_FAMILY_MARES_PUCK},
|
||||
{"darwin", DC_FAMILY_MARES_DARWIN},
|
||||
{"iconhd", DC_FAMILY_MARES_ICONHD},
|
||||
{"ostc", DC_FAMILY_HW_OSTC},
|
||||
{"frog", DC_FAMILY_HW_FROG},
|
||||
{"ostc3", DC_FAMILY_HW_OSTC3},
|
||||
{"edy", DC_FAMILY_CRESSI_EDY},
|
||||
{"leonardo", DC_FAMILY_CRESSI_LEONARDO},
|
||||
{"n2ition3", DC_FAMILY_ZEAGLE_N2ITION3},
|
||||
{"cobalt", DC_FAMILY_ATOMICS_COBALT},
|
||||
{"predator", DC_FAMILY_SHEARWATER_PREDATOR},
|
||||
{"petrel", DC_FAMILY_SHEARWATER_PETREL},
|
||||
{"nitekq", DC_FAMILY_DIVERITE_NITEKQ},
|
||||
{"aqualand", DC_FAMILY_CITIZEN_AQUALAND},
|
||||
{"idive", DC_FAMILY_DIVESYSTEM_IDIVE},
|
||||
};
|
||||
|
||||
static dc_family_t
|
||||
lookup_type (const char *name)
|
||||
{
|
||||
unsigned int nbackends = sizeof (g_backends) / sizeof (g_backends[0]);
|
||||
for (unsigned int i = 0; i < nbackends; ++i) {
|
||||
if (strcmp (name, g_backends[i].name) == 0)
|
||||
return g_backends[i].type;
|
||||
}
|
||||
|
||||
return DC_FAMILY_NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
lookup_name (dc_family_t type)
|
||||
{
|
||||
unsigned int nbackends = sizeof (g_backends) / sizeof (g_backends[0]);
|
||||
for (unsigned int i = 0; i < nbackends; ++i) {
|
||||
if (g_backends[i].type == type)
|
||||
return g_backends[i].name;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static unsigned char
|
||||
hex2dec (unsigned char value)
|
||||
{
|
||||
if (value >= '0' && value <= '9')
|
||||
return value - '0';
|
||||
else if (value >= 'A' && value <= 'F')
|
||||
return value - 'A' + 10;
|
||||
else if (value >= 'a' && value <= 'f')
|
||||
return value - 'a' + 10;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static dc_buffer_t *
|
||||
fpconvert (const char *fingerprint)
|
||||
{
|
||||
// Get the length of the fingerprint data.
|
||||
size_t nbytes = (fingerprint ? strlen (fingerprint) / 2 : 0);
|
||||
if (nbytes == 0)
|
||||
return NULL;
|
||||
|
||||
// Allocate a memory buffer.
|
||||
dc_buffer_t *buffer = dc_buffer_new (nbytes);
|
||||
|
||||
// Convert the hexadecimal string.
|
||||
for (unsigned int i = 0; i < nbytes; ++i) {
|
||||
unsigned char msn = hex2dec (fingerprint[i * 2 + 0]);
|
||||
unsigned char lsn = hex2dec (fingerprint[i * 2 + 1]);
|
||||
unsigned char byte = (msn << 4) + lsn;
|
||||
|
||||
dc_buffer_append (buffer, &byte, 1);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static dc_buffer_t *
|
||||
fpread (const char *dirname, dc_family_t backend, unsigned int serial)
|
||||
{
|
||||
// Build the filename.
|
||||
char filename[1024] = {0};
|
||||
snprintf (filename, sizeof (filename), "%s/%s-%08X.bin",
|
||||
dirname, lookup_name (backend), serial);
|
||||
|
||||
// Open the fingerprint file.
|
||||
FILE *fp = fopen (filename, "rb");
|
||||
if (fp == NULL)
|
||||
return NULL;
|
||||
|
||||
// Allocate a memory buffer.
|
||||
dc_buffer_t *buffer = dc_buffer_new (0);
|
||||
|
||||
// Read the entire file into the buffer.
|
||||
size_t n = 0;
|
||||
unsigned char block[1024] = {0};
|
||||
while ((n = fread (block, 1, sizeof (block), fp)) > 0) {
|
||||
dc_buffer_append (buffer, block, n);
|
||||
}
|
||||
|
||||
// Close the file.
|
||||
fclose (fp);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static void
|
||||
fpwrite (dc_buffer_t *buffer, const char *dirname, dc_family_t backend, unsigned int serial)
|
||||
{
|
||||
// Check the buffer size.
|
||||
if (dc_buffer_get_size (buffer) == 0)
|
||||
return;
|
||||
|
||||
// Build the filename.
|
||||
char filename[1024] = {0};
|
||||
snprintf (filename, sizeof (filename), "%s/%s-%08X.bin",
|
||||
dirname, lookup_name (backend), serial);
|
||||
|
||||
// Open the fingerprint file.
|
||||
FILE *fp = fopen (filename, "wb");
|
||||
if (fp == NULL)
|
||||
return;
|
||||
|
||||
// Write the fingerprint data.
|
||||
fwrite (dc_buffer_get_data (buffer), 1, dc_buffer_get_size (buffer), fp);
|
||||
|
||||
// Close the file.
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
volatile sig_atomic_t g_cancel = 0;
|
||||
|
||||
void
|
||||
sighandler (int signum)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
// Restore the default signal handler.
|
||||
signal (signum, SIG_DFL);
|
||||
#endif
|
||||
|
||||
g_cancel = 1;
|
||||
}
|
||||
|
||||
static int
|
||||
cancel_cb (void *userdata)
|
||||
{
|
||||
return g_cancel;
|
||||
}
|
||||
|
||||
void
|
||||
sample_cb (dc_sample_type_t type, dc_sample_value_t value, void *userdata)
|
||||
{
|
||||
static const char *events[] = {
|
||||
"none", "deco", "rbt", "ascent", "ceiling", "workload", "transmitter",
|
||||
"violation", "bookmark", "surface", "safety stop", "gaschange",
|
||||
"safety stop (voluntary)", "safety stop (mandatory)", "deepstop",
|
||||
"ceiling (safety stop)", "floor", "divetime", "maxdepth",
|
||||
"OLF", "PO2", "airtime", "rgbm", "heading", "tissue level warning",
|
||||
"gaschange2"};
|
||||
static const char *decostop[] = {
|
||||
"ndl", "safety", "deco", "deep"};
|
||||
|
||||
sample_data_t *sampledata = (sample_data_t *) userdata;
|
||||
|
||||
switch (type) {
|
||||
case DC_SAMPLE_TIME:
|
||||
if (sampledata->nsamples++)
|
||||
fprintf (sampledata->fp, "</sample>\n");
|
||||
fprintf (sampledata->fp, "<sample>\n");
|
||||
fprintf (sampledata->fp, " <time>%02u:%02u</time>\n", value.time / 60, value.time % 60);
|
||||
break;
|
||||
case DC_SAMPLE_DEPTH:
|
||||
fprintf (sampledata->fp, " <depth>%.2f</depth>\n", value.depth);
|
||||
break;
|
||||
case DC_SAMPLE_PRESSURE:
|
||||
fprintf (sampledata->fp, " <pressure tank=\"%u\">%.2f</pressure>\n", value.pressure.tank, value.pressure.value);
|
||||
break;
|
||||
case DC_SAMPLE_TEMPERATURE:
|
||||
fprintf (sampledata->fp, " <temperature>%.2f</temperature>\n", value.temperature);
|
||||
break;
|
||||
case DC_SAMPLE_EVENT:
|
||||
if (value.event.type == SAMPLE_EVENT_GASCHANGE2) {
|
||||
fprintf (sampledata->fp, " <gaschange o2=\"%u\" he=\"%u\" />\n",
|
||||
value.event.value & 0xFFFF, (value.event.value >> 16) & 0xFFFF);
|
||||
} else if (value.event.type == SAMPLE_EVENT_GASCHANGE) {
|
||||
fprintf (sampledata->fp, " <gaschange o2=\"%u\" />\n",
|
||||
value.event.value);
|
||||
} else {
|
||||
fprintf (sampledata->fp, " <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]);
|
||||
}
|
||||
break;
|
||||
case DC_SAMPLE_RBT:
|
||||
fprintf (sampledata->fp, " <rbt>%u</rbt>\n", value.rbt);
|
||||
break;
|
||||
case DC_SAMPLE_HEARTBEAT:
|
||||
fprintf (sampledata->fp, " <heartbeat>%u</heartbeat>\n", value.heartbeat);
|
||||
break;
|
||||
case DC_SAMPLE_BEARING:
|
||||
fprintf (sampledata->fp, " <bearing>%u</bearing>\n", value.bearing);
|
||||
break;
|
||||
case DC_SAMPLE_VENDOR:
|
||||
fprintf (sampledata->fp, " <vendor type=\"%u\" size=\"%u\">", value.vendor.type, value.vendor.size);
|
||||
for (unsigned int i = 0; i < value.vendor.size; ++i)
|
||||
fprintf (sampledata->fp, "%02X", ((unsigned char *) value.vendor.data)[i]);
|
||||
fprintf (sampledata->fp, "</vendor>\n");
|
||||
break;
|
||||
case DC_SAMPLE_SETPOINT:
|
||||
fprintf (sampledata->fp, " <setpoint>%.2f</setpoint>\n", value.setpoint);
|
||||
break;
|
||||
case DC_SAMPLE_PPO2:
|
||||
fprintf (sampledata->fp, " <ppo2>%.2f</ppo2>\n", value.ppo2);
|
||||
break;
|
||||
case DC_SAMPLE_CNS:
|
||||
fprintf (sampledata->fp, " <cns>%.1f</cns>\n", value.cns * 100.0);
|
||||
break;
|
||||
case DC_SAMPLE_DECO:
|
||||
fprintf (sampledata->fp, " <deco time=\"%u\" depth=\"%.2f\">%s</deco>\n",
|
||||
value.deco.time, value.deco.depth, decostop[value.deco.type]);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static dc_status_t
|
||||
doparse (FILE *fp, dc_device_t *device, const unsigned char data[], unsigned int size)
|
||||
{
|
||||
// Create the parser.
|
||||
message ("Creating the parser.\n");
|
||||
dc_parser_t *parser = NULL;
|
||||
dc_status_t rc = dc_parser_new (&parser, device);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error creating the parser.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Register the data.
|
||||
message ("Registering the data.\n");
|
||||
rc = dc_parser_set_data (parser, data, size);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error registering the data.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Parse the datetime.
|
||||
message ("Parsing the datetime.\n");
|
||||
dc_datetime_t dt = {0};
|
||||
rc = dc_parser_get_datetime (parser, &dt);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the datetime.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp, "<datetime>%04i-%02i-%02i %02i:%02i:%02i</datetime>\n",
|
||||
dt.year, dt.month, dt.day,
|
||||
dt.hour, dt.minute, dt.second);
|
||||
|
||||
// Parse the divetime.
|
||||
message ("Parsing the divetime.\n");
|
||||
unsigned int divetime = 0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_DIVETIME, 0, &divetime);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the divetime.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp, "<divetime>%02u:%02u</divetime>\n",
|
||||
divetime / 60, divetime % 60);
|
||||
|
||||
// Parse the temperature.
|
||||
message ("Parsing the temperature.\n");
|
||||
for (unsigned int i = 0; i < 3; ++i) {
|
||||
dc_field_type_t fields[] = {DC_FIELD_TEMPERATURE_SURFACE,
|
||||
DC_FIELD_TEMPERATURE_MINIMUM,
|
||||
DC_FIELD_TEMPERATURE_MAXIMUM};
|
||||
const char *names[] = {"surface", "minimum", "maximum"};
|
||||
|
||||
double temperature = 0.0;
|
||||
rc = dc_parser_get_field (parser, fields[i], 0, &temperature);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the temperature.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_UNSUPPORTED) {
|
||||
fprintf (fp, "<temperature type=\"%s\">%.1f</temperature>\n",
|
||||
names[i], temperature);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the maxdepth.
|
||||
message ("Parsing the maxdepth.\n");
|
||||
double maxdepth = 0.0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_MAXDEPTH, 0, &maxdepth);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the maxdepth.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp, "<maxdepth>%.2f</maxdepth>\n",
|
||||
maxdepth);
|
||||
|
||||
// Parse the gas mixes.
|
||||
message ("Parsing the gas mixes.\n");
|
||||
unsigned int ngases = 0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_GASMIX_COUNT, 0, &ngases);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the gas mix count.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ngases; ++i) {
|
||||
dc_gasmix_t gasmix = {0};
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_GASMIX, i, &gasmix);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the gas mix.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp,
|
||||
"<gasmix>\n"
|
||||
" <he>%.1f</he>\n"
|
||||
" <o2>%.1f</o2>\n"
|
||||
" <n2>%.1f</n2>\n"
|
||||
"</gasmix>\n",
|
||||
gasmix.helium * 100.0,
|
||||
gasmix.oxygen * 100.0,
|
||||
gasmix.nitrogen * 100.0);
|
||||
}
|
||||
|
||||
// Parse the tanks.
|
||||
message ("Parsing the tanks.\n");
|
||||
unsigned int ntanks = 0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_TANK_COUNT, 0, &ntanks);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the tank count.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < ntanks; ++i) {
|
||||
const char *names[] = {"none", "metric", "imperial"};
|
||||
|
||||
dc_tank_t tank = {0};
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_TANK, i, &tank);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the tank.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
fprintf (fp, "<tank>\n");
|
||||
if (tank.gasmix != DC_GASMIX_UNKNOWN) {
|
||||
fprintf (fp,
|
||||
" <gasmix>%u</gasmix>\n",
|
||||
tank.gasmix);
|
||||
}
|
||||
if (tank.type != DC_TANKVOLUME_NONE) {
|
||||
fprintf (fp,
|
||||
" <type>%s</type>\n"
|
||||
" <volume>%.1f</volume>\n"
|
||||
" <workpressure>%.2f</workpressure>\n",
|
||||
names[tank.type], tank.volume, tank.workpressure);
|
||||
}
|
||||
fprintf (fp,
|
||||
" <beginpressure>%.2f</beginpressure>\n"
|
||||
" <endpressure>%.2f</endpressure>\n"
|
||||
"</tank>\n",
|
||||
tank.beginpressure, tank.endpressure);
|
||||
}
|
||||
|
||||
// Parse the dive mode.
|
||||
message ("Parsing the dive mode.\n");
|
||||
dc_divemode_t divemode = DC_DIVEMODE_OC;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_DIVEMODE, 0, &divemode);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the dive mode.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_UNSUPPORTED) {
|
||||
const char *names[] = {"freedive", "gauge", "oc", "cc"};
|
||||
fprintf (fp, "<divemode>%s</divemode>\n",
|
||||
names[divemode]);
|
||||
}
|
||||
|
||||
// Parse the salinity.
|
||||
message ("Parsing the salinity.\n");
|
||||
dc_salinity_t salinity = {DC_WATER_FRESH, 0.0};
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_SALINITY, 0, &salinity);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the salinity.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_UNSUPPORTED) {
|
||||
fprintf (fp, "<salinity type=\"%u\">%.1f</salinity>\n",
|
||||
salinity.type, salinity.density);
|
||||
}
|
||||
|
||||
// Parse the atmospheric pressure.
|
||||
message ("Parsing the atmospheric pressure.\n");
|
||||
double atmospheric = 0.0;
|
||||
rc = dc_parser_get_field (parser, DC_FIELD_ATMOSPHERIC, 0, &atmospheric);
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_UNSUPPORTED) {
|
||||
WARNING ("Error parsing the atmospheric pressure.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_UNSUPPORTED) {
|
||||
fprintf (fp, "<atmospheric>%.5f</atmospheric>\n",
|
||||
atmospheric);
|
||||
}
|
||||
|
||||
// Initialize the sample data.
|
||||
sample_data_t sampledata = {0};
|
||||
sampledata.nsamples = 0;
|
||||
sampledata.fp = fp;
|
||||
|
||||
// Parse the sample data.
|
||||
message ("Parsing the sample data.\n");
|
||||
rc = dc_parser_samples_foreach (parser, sample_cb, &sampledata);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error parsing the sample data.");
|
||||
dc_parser_destroy (parser);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (sampledata.nsamples)
|
||||
fprintf (fp, "</sample>\n");
|
||||
|
||||
// Destroy the parser.
|
||||
message ("Destroying the parser.\n");
|
||||
rc = dc_parser_destroy (parser);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error destroying the parser.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
event_cb (dc_device_t *device, dc_event_type_t event, const void *data, void *userdata)
|
||||
{
|
||||
const dc_event_progress_t *progress = (dc_event_progress_t *) data;
|
||||
const dc_event_devinfo_t *devinfo = (dc_event_devinfo_t *) data;
|
||||
const dc_event_clock_t *clock = (dc_event_clock_t *) data;
|
||||
const dc_event_vendor_t *vendor = (dc_event_vendor_t *) data;
|
||||
|
||||
device_data_t *devdata = (device_data_t *) userdata;
|
||||
|
||||
switch (event) {
|
||||
case DC_EVENT_WAITING:
|
||||
message ("Event: waiting for user action\n");
|
||||
break;
|
||||
case DC_EVENT_PROGRESS:
|
||||
message ("Event: progress %3.2f%% (%u/%u)\n",
|
||||
100.0 * (double) progress->current / (double) progress->maximum,
|
||||
progress->current, progress->maximum);
|
||||
break;
|
||||
case DC_EVENT_DEVINFO:
|
||||
devdata->devinfo = *devinfo;
|
||||
message ("Event: model=%u (0x%08x), firmware=%u (0x%08x), serial=%u (0x%08x)\n",
|
||||
devinfo->model, devinfo->model,
|
||||
devinfo->firmware, devinfo->firmware,
|
||||
devinfo->serial, devinfo->serial);
|
||||
if (g_cachedir && g_cachedir_read) {
|
||||
dc_buffer_t *fingerprint = fpread (g_cachedir, dc_device_get_type (device), devinfo->serial);
|
||||
dc_device_set_fingerprint (device,
|
||||
dc_buffer_get_data (fingerprint),
|
||||
dc_buffer_get_size (fingerprint));
|
||||
dc_buffer_free (fingerprint);
|
||||
}
|
||||
break;
|
||||
case DC_EVENT_CLOCK:
|
||||
devdata->clock = *clock;
|
||||
message ("Event: systime=" DC_TICKS_FORMAT ", devtime=%u\n",
|
||||
clock->systime, clock->devtime);
|
||||
break;
|
||||
case DC_EVENT_VENDOR:
|
||||
message ("Event: vendor=");
|
||||
for (unsigned int i = 0; i < vendor->size; ++i)
|
||||
message ("%02X", vendor->data[i]);
|
||||
message ("\n");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
dive_cb (const unsigned char *data, unsigned int size, const unsigned char *fingerprint, unsigned int fsize, void *userdata)
|
||||
{
|
||||
dive_data_t *divedata = (dive_data_t *) userdata;
|
||||
|
||||
divedata->number++;
|
||||
|
||||
message ("Dive: number=%u, size=%u, fingerprint=", divedata->number, size);
|
||||
for (unsigned int i = 0; i < fsize; ++i)
|
||||
message ("%02X", fingerprint[i]);
|
||||
message ("\n");
|
||||
|
||||
if (divedata->number == 1) {
|
||||
divedata->fingerprint = dc_buffer_new (fsize);
|
||||
dc_buffer_append (divedata->fingerprint, fingerprint, fsize);
|
||||
}
|
||||
|
||||
if (divedata->fp) {
|
||||
fprintf (divedata->fp, "<dive>\n<number>%u</number>\n<size>%u</size>\n<fingerprint>", divedata->number, size);
|
||||
for (unsigned int i = 0; i < fsize; ++i)
|
||||
fprintf (divedata->fp, "%02X", fingerprint[i]);
|
||||
fprintf (divedata->fp, "</fingerprint>\n");
|
||||
|
||||
doparse (divedata->fp, divedata->device, data, size);
|
||||
|
||||
fprintf (divedata->fp, "</dive>\n");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage (const char *filename)
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
fprintf (stderr, "Usage:\n\n");
|
||||
fprintf (stderr, " %s [options] devname\n\n", filename);
|
||||
fprintf (stderr, "Options:\n\n");
|
||||
fprintf (stderr, " -n name Set device name (required).\n");
|
||||
fprintf (stderr, " -b name Set backend name (required).\n");
|
||||
fprintf (stderr, " -t model Set model code.\n");
|
||||
fprintf (stderr, " -f hexdata Set fingerprint data.\n");
|
||||
fprintf (stderr, " -l logfile Set logfile.\n");
|
||||
fprintf (stderr, " -d filename Download dives.\n");
|
||||
fprintf (stderr, " -m filename Download memory dump.\n");
|
||||
fprintf (stderr, " -c cachedir Set cache directory.\n");
|
||||
fprintf (stderr, " -h Show this help message.\n\n");
|
||||
#else
|
||||
fprintf (stderr, "Usage:\n\n");
|
||||
fprintf (stderr, " %s backend devname\n\n", filename);
|
||||
#endif
|
||||
|
||||
fprintf (stderr, "Supported backends:\n\n");
|
||||
unsigned int nbackends = sizeof (g_backends) / sizeof (g_backends[0]);
|
||||
for (unsigned int i = 0; i < nbackends; ++i) {
|
||||
fprintf (stderr, "%s", g_backends[i].name);
|
||||
if (i != nbackends - 1)
|
||||
fprintf (stderr, ", ");
|
||||
else
|
||||
fprintf (stderr, "\n\n");
|
||||
}
|
||||
|
||||
fprintf (stderr, "Supported devices:\n\n");
|
||||
dc_iterator_t *iterator = NULL;
|
||||
dc_descriptor_t *descriptor = NULL;
|
||||
dc_descriptor_iterator (&iterator);
|
||||
while (dc_iterator_next (iterator, &descriptor) == DC_STATUS_SUCCESS) {
|
||||
fprintf (stderr, " %s %s\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor));
|
||||
dc_descriptor_free (descriptor);
|
||||
}
|
||||
dc_iterator_free (iterator);
|
||||
}
|
||||
|
||||
|
||||
static dc_status_t
|
||||
search (dc_descriptor_t **out, const char *name, dc_family_t backend, unsigned int model)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
|
||||
dc_iterator_t *iterator = NULL;
|
||||
rc = dc_descriptor_iterator (&iterator);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error creating the device descriptor iterator.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
dc_descriptor_t *descriptor = NULL, *current = NULL;
|
||||
while ((rc = dc_iterator_next (iterator, &descriptor)) == DC_STATUS_SUCCESS) {
|
||||
if (name) {
|
||||
const char *vendor = dc_descriptor_get_vendor (descriptor);
|
||||
const char *product = dc_descriptor_get_product (descriptor);
|
||||
|
||||
size_t n = strlen (vendor);
|
||||
if (strncasecmp (name, vendor, n) == 0 && name[n] == ' ' &&
|
||||
strcasecmp (name + n + 1, product) == 0)
|
||||
{
|
||||
current = descriptor;
|
||||
break;
|
||||
} else if (strcasecmp (name, product) == 0) {
|
||||
current = descriptor;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (backend == dc_descriptor_get_type (descriptor)) {
|
||||
if (model == dc_descriptor_get_model (descriptor)) {
|
||||
// Exact match found. Return immediately.
|
||||
dc_descriptor_free (current);
|
||||
current = descriptor;
|
||||
break;
|
||||
} else {
|
||||
// Possible match found. Keep searching for an exact match.
|
||||
// If no exact match is found, the first match is returned.
|
||||
if (current == NULL) {
|
||||
current = descriptor;
|
||||
descriptor = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dc_descriptor_free (descriptor);
|
||||
}
|
||||
|
||||
if (rc != DC_STATUS_SUCCESS && rc != DC_STATUS_DONE) {
|
||||
dc_descriptor_free (current);
|
||||
dc_iterator_free (iterator);
|
||||
WARNING ("Error iterating the device descriptors.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
dc_iterator_free (iterator);
|
||||
|
||||
*out = current;
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static dc_status_t
|
||||
dowork (dc_context_t *context, dc_descriptor_t *descriptor, const char *devname, const char *rawfile, const char *xmlfile, int memory, int dives, dc_buffer_t *fingerprint)
|
||||
{
|
||||
dc_status_t rc = DC_STATUS_SUCCESS;
|
||||
|
||||
// Initialize the device data.
|
||||
device_data_t devdata = {{0}};
|
||||
|
||||
// Open the device.
|
||||
message ("Opening the device (%s %s, %s).\n",
|
||||
dc_descriptor_get_vendor (descriptor),
|
||||
dc_descriptor_get_product (descriptor),
|
||||
devname ? devname : "null");
|
||||
dc_device_t *device = NULL;
|
||||
rc = dc_device_open (&device, context, descriptor, devname);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error opening device.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Register the event handler.
|
||||
message ("Registering the event handler.\n");
|
||||
int events = DC_EVENT_WAITING | DC_EVENT_PROGRESS | DC_EVENT_DEVINFO | DC_EVENT_CLOCK | DC_EVENT_VENDOR;
|
||||
rc = dc_device_set_events (device, events, event_cb, &devdata);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error registering the event handler.");
|
||||
dc_device_close (device);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Register the cancellation handler.
|
||||
message ("Registering the cancellation handler.\n");
|
||||
rc = dc_device_set_cancel (device, cancel_cb, NULL);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error registering the cancellation handler.");
|
||||
dc_device_close (device);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Register the fingerprint data.
|
||||
if (fingerprint) {
|
||||
message ("Registering the fingerprint data.\n");
|
||||
rc = dc_device_set_fingerprint (device, dc_buffer_get_data (fingerprint), dc_buffer_get_size (fingerprint));
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error registering the fingerprint data.");
|
||||
dc_device_close (device);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
if (memory) {
|
||||
// Allocate a memory buffer.
|
||||
dc_buffer_t *buffer = dc_buffer_new (0);
|
||||
|
||||
// Download the memory dump.
|
||||
message ("Downloading the memory dump.\n");
|
||||
rc = dc_device_dump (device, buffer);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error downloading the memory dump.");
|
||||
dc_buffer_free (buffer);
|
||||
dc_device_close (device);
|
||||
return rc;
|
||||
}
|
||||
|
||||
// Write the memory dump to disk.
|
||||
FILE* fp = fopen (rawfile, "wb");
|
||||
if (fp != NULL) {
|
||||
fwrite (dc_buffer_get_data (buffer), 1, dc_buffer_get_size (buffer), fp);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
// Free the memory buffer.
|
||||
dc_buffer_free (buffer);
|
||||
}
|
||||
|
||||
if (dives) {
|
||||
// Initialize the dive data.
|
||||
dive_data_t divedata = {0};
|
||||
divedata.device = device;
|
||||
divedata.fingerprint = NULL;
|
||||
divedata.number = 0;
|
||||
|
||||
// Open the output file.
|
||||
divedata.fp = fopen (xmlfile, "w");
|
||||
|
||||
if (divedata.fp) {
|
||||
fprintf (divedata.fp, "<device>\n");
|
||||
}
|
||||
|
||||
// Download the dives.
|
||||
message ("Downloading the dives.\n");
|
||||
rc = dc_device_foreach (device, dive_cb, &divedata);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error downloading the dives.");
|
||||
dc_buffer_free (divedata.fingerprint);
|
||||
if (divedata.fp) fclose (divedata.fp);
|
||||
dc_device_close (device);
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (divedata.fp) {
|
||||
fprintf (divedata.fp, "</device>\n");
|
||||
}
|
||||
|
||||
// Store the fingerprint data.
|
||||
if (g_cachedir) {
|
||||
fpwrite (divedata.fingerprint, g_cachedir, dc_device_get_type (device), devdata.devinfo.serial);
|
||||
}
|
||||
|
||||
// Free the fingerprint buffer.
|
||||
dc_buffer_free (divedata.fingerprint);
|
||||
|
||||
// Close the output file.
|
||||
if (divedata.fp) fclose (divedata.fp);
|
||||
}
|
||||
|
||||
// Close the device.
|
||||
message ("Closing the device.\n");
|
||||
rc = dc_device_close (device);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
WARNING ("Error closing the device.");
|
||||
return rc;
|
||||
}
|
||||
|
||||
return DC_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
// Default values.
|
||||
dc_family_t backend = DC_FAMILY_NULL;
|
||||
dc_loglevel_t loglevel = DC_LOGLEVEL_WARNING;
|
||||
const char *name = NULL;
|
||||
const char *logfile = "output.log";
|
||||
const char *rawfile = "output.bin";
|
||||
const char *xmlfile = "output.xml";
|
||||
const char *devname = NULL;
|
||||
const char *fingerprint = NULL;
|
||||
unsigned int model = 0;
|
||||
int memory = 0, dives = 0;
|
||||
|
||||
#ifndef _MSC_VER
|
||||
// Parse command-line options.
|
||||
int opt = 0;
|
||||
while ((opt = getopt (argc, argv, "n:b:t:f:l:m:d:c:vh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'n':
|
||||
name = optarg;
|
||||
break;
|
||||
case 'b':
|
||||
backend = lookup_type (optarg);
|
||||
break;
|
||||
case 't':
|
||||
model = strtoul (optarg, NULL, 0);
|
||||
break;
|
||||
case 'f':
|
||||
fingerprint = optarg;
|
||||
g_cachedir_read = 0;
|
||||
break;
|
||||
case 'l':
|
||||
logfile = optarg;
|
||||
break;
|
||||
case 'v':
|
||||
loglevel++;
|
||||
break;
|
||||
case 'm':
|
||||
memory = 1;
|
||||
rawfile = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
dives = 1;
|
||||
xmlfile = optarg;
|
||||
break;
|
||||
case 'c':
|
||||
g_cachedir = optarg;
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
default:
|
||||
usage (argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
devname = argv[optind];
|
||||
#else
|
||||
if (argc > 1)
|
||||
backend = lookup_type (argv[1]);
|
||||
|
||||
if (argc > 2)
|
||||
devname = argv[2];
|
||||
#endif
|
||||
|
||||
// Set the default action.
|
||||
if (!memory && !dives) {
|
||||
memory = 1;
|
||||
dives = 1;
|
||||
}
|
||||
|
||||
signal (SIGINT, sighandler);
|
||||
|
||||
message_set_logfile (logfile);
|
||||
|
||||
dc_context_t *context = NULL;
|
||||
dc_status_t rc = dc_context_new (&context);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
message_set_logfile (NULL);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
dc_context_set_loglevel (context, loglevel);
|
||||
dc_context_set_logfunc (context, logfunc, NULL);
|
||||
|
||||
/* Search for a matching device descriptor. */
|
||||
dc_descriptor_t *descriptor = NULL;
|
||||
rc = search (&descriptor, name, backend, model);
|
||||
if (rc != DC_STATUS_SUCCESS) {
|
||||
message_set_logfile (NULL);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
/* Fail if no device descriptor found. */
|
||||
if (descriptor == NULL) {
|
||||
WARNING ("No matching device found.");
|
||||
usage (argv[0]);
|
||||
message_set_logfile (NULL);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
dc_buffer_t *fp = fpconvert (fingerprint);
|
||||
rc = dowork (context, descriptor, devname, rawfile, xmlfile, memory, dives, fp);
|
||||
dc_buffer_free (fp);
|
||||
message ("Result: %s\n", errmsg (rc));
|
||||
|
||||
dc_descriptor_free (descriptor);
|
||||
dc_context_free (context);
|
||||
|
||||
message_set_logfile (NULL);
|
||||
|
||||
return rc != DC_STATUS_SUCCESS ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
@ -26,28 +26,9 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#endif
|
||||
#define WARNING(expr) message ("%s:%d: %s\n", __FILE__, __LINE__, expr)
|
||||
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
|
||||
#define FUNCTION __func__
|
||||
#else
|
||||
#define FUNCTION __FUNCTION__
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define ATTR_FORMAT_PRINTF(a,b) __attribute__((format(printf, a, b)))
|
||||
#else
|
||||
#define ATTR_FORMAT_PRINTF(a,b)
|
||||
#endif
|
||||
|
||||
#define WARNING(expr) message("WARNING: %s [in %s:%d (%s)]\n", expr, __FILE__, __LINE__, FUNCTION)
|
||||
#define ERROR(expr) message("ERROR: %s [in %s:%d (%s)]\n", expr, __FILE__, __LINE__, FUNCTION)
|
||||
|
||||
int message (const char* fmt, ...) ATTR_FORMAT_PRINTF(1, 2);
|
||||
int message (const char* fmt, ...);
|
||||
|
||||
void message_set_logfile (const char* filename);
|
||||
|
||||
|
||||
@ -6,30 +6,52 @@ libdivecomputer_HEADERS = \
|
||||
buffer.h \
|
||||
descriptor.h \
|
||||
iterator.h \
|
||||
iostream.h \
|
||||
ioctl.h \
|
||||
serial.h \
|
||||
bluetooth.h \
|
||||
ble.h \
|
||||
irda.h \
|
||||
usb.h \
|
||||
usbhid.h \
|
||||
custom.h \
|
||||
device.h \
|
||||
parser.h \
|
||||
datetime.h \
|
||||
units.h \
|
||||
suunto.h \
|
||||
suunto_solution.h \
|
||||
suunto_eon.h \
|
||||
suunto_vyper.h \
|
||||
suunto_vyper2.h \
|
||||
suunto_d9.h \
|
||||
reefnet.h \
|
||||
reefnet_sensus.h \
|
||||
reefnet_sensuspro.h \
|
||||
reefnet_sensusultra.h \
|
||||
uwatec.h \
|
||||
uwatec_aladin.h \
|
||||
uwatec_memomouse.h \
|
||||
uwatec_smart.h \
|
||||
uwatec_meridian.h \
|
||||
oceanic.h \
|
||||
oceanic_atom2.h \
|
||||
oceanic_veo250.h \
|
||||
oceanic_vtpro.h \
|
||||
mares.h \
|
||||
mares_nemo.h \
|
||||
mares_puck.h \
|
||||
mares_darwin.h \
|
||||
mares_iconhd.h \
|
||||
hw.h \
|
||||
hw_ostc.h \
|
||||
hw_frog.h \
|
||||
hw_ostc3.h \
|
||||
cressi.h \
|
||||
cressi_edy.h \
|
||||
cressi_leonardo.h \
|
||||
zeagle.h \
|
||||
zeagle_n2ition3.h \
|
||||
atomics.h \
|
||||
atomics_cobalt.h \
|
||||
divesystem_idive.h
|
||||
shearwater.h \
|
||||
shearwater_petrel.h \
|
||||
shearwater_predator.h \
|
||||
diverite.h \
|
||||
diverite_nitekq.h \
|
||||
citizen.h \
|
||||
citizen_aqualand.h \
|
||||
divesystem.h \
|
||||
divesystem_idive.h \
|
||||
custom_serial.h
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* libdivecomputer
|
||||
*
|
||||
* Copyright (C) 2015 Jef Driesen
|
||||
* Copyright (C) 2011 Jef Driesen
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@ -19,16 +19,9 @@
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#ifndef ATOMICS_H
|
||||
#define ATOMICS_H
|
||||
|
||||
#include "common-private.h"
|
||||
#include "atomics_cobalt.h"
|
||||
|
||||
void
|
||||
dc_status_set_error (dc_status_t *status, dc_status_t error)
|
||||
{
|
||||
assert (status != NULL);
|
||||
|
||||
if (*status == DC_STATUS_SUCCESS)
|
||||
*status = error;
|
||||
}
|
||||
#endif /* ATOMICS_H */
|
||||
@ -19,10 +19,10 @@
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef DC_ATOMICS_COBALT_H
|
||||
#define DC_ATOMICS_COBALT_H
|
||||
#ifndef ATOMICS_COBALT_H
|
||||
#define ATOMICS_COBALT_H
|
||||
|
||||
#include "common.h"
|
||||
#include "context.h"
|
||||
#include "device.h"
|
||||
#include "parser.h"
|
||||
|
||||
@ -30,13 +30,22 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
dc_status_t
|
||||
atomics_cobalt_device_open (dc_device_t **device, dc_context_t *context);
|
||||
|
||||
dc_status_t
|
||||
atomics_cobalt_device_version (dc_device_t *device, unsigned char data[], unsigned int size);
|
||||
|
||||
dc_status_t
|
||||
atomics_cobalt_device_set_simulation (dc_device_t *device, unsigned int simulation);
|
||||
|
||||
dc_status_t
|
||||
atomics_cobalt_parser_create (dc_parser_t **parser, dc_context_t *context);
|
||||
|
||||
dc_status_t
|
||||
atomics_cobalt_parser_set_calibration (dc_parser_t *parser, double atmospheric, double hydrostatic);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* DC_ATOMICS_COBALT_H */
|
||||
#endif /* ATOMICS_COBALT_H */
|
||||
|
||||
@ -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 */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user