Merge branch 'master' of git://github.com/libdivecomputer/libdivecomputer into Subsurface-DS9

Merge upstream libdivecomputer updates by Jef Driesen:

 - fix HW Sport and Mares Genius firmware update

 - Windows Visual Studio build updates

 - Various parser updates:
    - sporasub depth, salinity and sample rate parsing
    - Atomics Cobalt atmospheric pressure parsing
    - unit cleanups (Uwatec, McLean Extreme)

* git://github.com/libdivecomputer/libdivecomputer:
  Some more fixes for the new Mares Genius firmware
  Implement the salinity field
  Fix the sample rate parsing
  Add support for the new Mares Genius firmware
  Use the correct standard gravity factor
  Use SI units internally
  Fix negative depth values
  Move the unit conversion to the last moment
  Implement the atmospheric pressure field
  Always use the stored atmospheric pressure
  Add a CI job to build with Visual Studio
  Migrate to Visual Studio 2013 (or newer)
  Emit events when downloading a memory dump
  Fix the depth decoding
  Add library dependencies in windows build
  Fix the hwOS Sport firmware upgrade
  Post release version bump to 0.8.0
This commit is contained in:
Linus Torvalds 2021-07-19 14:30:55 -07:00
commit 3e87ed050c
15 changed files with 543 additions and 1082 deletions

View File

@ -81,8 +81,37 @@ jobs:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Install dependencies - name: Install dependencies
run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools run: sudo apt-get install gcc-mingw-w64 binutils-mingw-w64 mingw-w64-tools
- name: Install libusb
env:
LIBUSB_VERSION: 1.0.24
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.10.1
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
make
make install DESTDIR=$PWD/../artifacts
popd
- run: autoreconf --install --force - run: autoreconf --install --force
- run: ./configure --host=${{ matrix.arch }}-w64-mingw32 --prefix=/usr - 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
- run: make distcheck - run: make distcheck
- name: Package artifacts - name: Package artifacts
@ -93,3 +122,33 @@ jobs:
with: with:
name: ${{ github.job }}-${{ matrix.arch }} name: ${{ github.job }}-${{ matrix.arch }}
path: ${{ github.job }}-${{ matrix.arch }}.tar.gz 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@v2
- uses: msys2/setup-msys2@v2
with:
install: autoconf automake libtool pkg-config make gcc
- run: |
autoreconf --install --force
./configure --prefix=/usr
shell: msys2 {0}
- uses: microsoft/setup-msbuild@v1.0.2
- run: msbuild -m -p:Platform=${{ matrix.platform }} -p:Configuration=${{ env.CONFIGURATION }} msvc/libdivecomputer.vcxproj
- uses: actions/upload-artifact@v2
with:
name: ${{ github.job }}-${{ matrix.platform }}
path: msvc/${{ matrix.platform }}/${{ env.CONFIGURATION }}/bin

5
.gitignore vendored
View File

@ -47,11 +47,10 @@ Makefile.in
/m4/ltsugar.m4 /m4/ltsugar.m4
/m4/ltversion.m4 /m4/ltversion.m4
/msvc/Debug/ /msvc/x64/
/msvc/Release/ /msvc/x86/
/msvc/*.ncb /msvc/*.ncb
/msvc/*.suo /msvc/*.suo
/msvc/*.vcproj.*.user
/src/libdivecomputer.exp /src/libdivecomputer.exp
/src/libdivecomputer.la /src/libdivecomputer.la

View File

@ -16,4 +16,5 @@ pkgconfig_DATA = libdivecomputer.pc
EXTRA_DIST = \ EXTRA_DIST = \
libdivecomputer.pc.in \ libdivecomputer.pc.in \
msvc/libdivecomputer.vcproj msvc/libdivecomputer.vcxproj \
msvc/libdivecomputer.vcxproj.filters

View File

@ -1,8 +1,8 @@
# Versioning. # Versioning.
m4_define([dc_version_major],[0]) m4_define([dc_version_major],[0])
m4_define([dc_version_minor],[7]) m4_define([dc_version_minor],[8])
m4_define([dc_version_micro],[0]) m4_define([dc_version_micro],[0])
m4_define([dc_version_suffix],[Subsurface-NG]) m4_define([dc_version_suffix],[devel-Subsurface-NG])
m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix])) m4_define([dc_version],dc_version_major.dc_version_minor.dc_version_micro[]m4_ifset([dc_version_suffix],-[dc_version_suffix]))
# Libtool versioning. # Libtool versioning.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,374 @@
<?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_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>
</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_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>
</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_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>
</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_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>
</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\descriptor.c" />
<ClCompile Include="..\src\device.c" />
<ClCompile Include="..\src\diverite_nitekq.c" />
<ClCompile Include="..\src\diverite_nitekq_parser.c" />
<ClCompile Include="..\src\divesystem_idive.c" />
<ClCompile Include="..\src\divesystem_idive_parser.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\parser.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\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\descriptor-private.h" />
<ClInclude Include="..\src\device-private.h" />
<ClInclude Include="..\src\diverite_nitekq.h" />
<ClInclude Include="..\src\divesystem_idive.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\parser-private.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\shearwater_common.h" />
<ClInclude Include="..\src\shearwater_petrel.h" />
<ClInclude Include="..\src\shearwater_predator.h" />
<ClInclude Include="..\src\socket.h" />
<ClInclude Include="..\src\sporasub_sp2.h" />
<ClInclude Include="..\src\suunto_common.h" />
<ClInclude Include="..\src\suunto_common2.h" />
<ClInclude Include="..\src\suunto_d9.h" />
<ClInclude Include="..\src\suunto_eon.h" />
<ClInclude Include="..\src\suunto_eonsteel.h" />
<ClInclude Include="..\src\suunto_solution.h" />
<ClInclude Include="..\src\suunto_vyper.h" />
<ClInclude Include="..\src\suunto_vyper2.h" />
<ClInclude Include="..\src\tecdiving_divecomputereu.h" />
<ClInclude Include="..\src\timer.h" />
<ClInclude Include="..\src\uwatec_aladin.h" />
<ClInclude Include="..\src\uwatec_memomouse.h" />
<ClInclude Include="..\src\uwatec_smart.h" />
<ClInclude Include="..\src\zeagle_n2ition3.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\src\libdivecomputer.rc" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\src\libdivecomputer.symbols">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo EXPORTS &gt; "$(OutDir)libdivecomputer.def" &amp;&amp; type "%(FullPath)" &gt;&gt; "$(OutDir)libdivecomputer.def"</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)libdivecomputer.def;%(Outputs)</Outputs>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

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

View File

@ -46,7 +46,6 @@ typedef struct atomics_cobalt_parser_t atomics_cobalt_parser_t;
struct atomics_cobalt_parser_t { struct atomics_cobalt_parser_t {
dc_parser_t base; dc_parser_t base;
// Depth calibration. // Depth calibration.
double atmospheric;
double hydrostatic; double hydrostatic;
}; };
@ -82,7 +81,6 @@ atomics_cobalt_parser_create (dc_parser_t **out, dc_context_t *context)
} }
// Set the default values. // Set the default values.
parser->atmospheric = 0.0;
parser->hydrostatic = 1025.0 * GRAVITY; parser->hydrostatic = 1025.0 * GRAVITY;
*out = (dc_parser_t*) parser; *out = (dc_parser_t*) parser;
@ -106,7 +104,6 @@ atomics_cobalt_parser_set_calibration (dc_parser_t *abstract, double atmospheric
if (!ISINSTANCE (abstract)) if (!ISINSTANCE (abstract))
return DC_STATUS_INVALIDARGS; return DC_STATUS_INVALIDARGS;
parser->atmospheric = atmospheric;
parser->hydrostatic = hydrostatic; parser->hydrostatic = hydrostatic;
return DC_STATUS_SUCCESS; return DC_STATUS_SUCCESS;
@ -151,15 +148,10 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
dc_gasmix_t *gasmix = (dc_gasmix_t *) value; dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
dc_tank_t *tank = (dc_tank_t *) value; dc_tank_t *tank = (dc_tank_t *) value;
double atmospheric = 0.0; unsigned int atmospheric = array_uint16_le (p + 0x26);
char buf[BUFLEN]; char buf[BUFLEN];
dc_field_string_t *string = (dc_field_string_t *) value; dc_field_string_t *string = (dc_field_string_t *) value;
if (parser->atmospheric)
atmospheric = parser->atmospheric;
else
atmospheric = array_uint16_le (p + 0x26) * BAR / 1000.0;
unsigned int workpressure = 0; unsigned int workpressure = 0;
if (value) { if (value) {
@ -168,7 +160,7 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
*((unsigned int *) value) = array_uint16_le (p + 0x58) * 60; *((unsigned int *) value) = array_uint16_le (p + 0x58) * 60;
break; break;
case DC_FIELD_MAXDEPTH: case DC_FIELD_MAXDEPTH:
*((double *) value) = (array_uint16_le (p + 0x56) * BAR / 1000.0 - atmospheric) / parser->hydrostatic; *((double *) value) = (signed int)(array_uint16_le (p + 0x56) - atmospheric) * (BAR / 1000.0) / parser->hydrostatic;
break; break;
case DC_FIELD_GASMIX_COUNT: case DC_FIELD_GASMIX_COUNT:
case DC_FIELD_TANK_COUNT: case DC_FIELD_TANK_COUNT:
@ -220,6 +212,9 @@ atomics_cobalt_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, un
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
} }
break; break;
case DC_FIELD_ATMOSPHERIC:
*((double *) value) = atmospheric / 1000.0;
break;
case DC_FIELD_STRING: case DC_FIELD_STRING:
switch(flags) { switch(flags) {
case 0: // Serialnr case 0: // Serialnr
@ -274,11 +269,7 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
if (size < header + SZ_SEGMENT * nsegments) if (size < header + SZ_SEGMENT * nsegments)
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
double atmospheric = 0.0; unsigned int atmospheric = array_uint16_le (data + 0x26);
if (parser->atmospheric)
atmospheric = parser->atmospheric;
else
atmospheric = array_uint16_le (data + 0x26) * BAR / 1000.0;
// Previous gas mix - initialize with impossible value // Previous gas mix - initialize with impossible value
unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int gasmix_previous = 0xFFFFFFFF;
@ -309,7 +300,7 @@ atomics_cobalt_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback
// Depth (1/1000 bar). // Depth (1/1000 bar).
unsigned int depth = array_uint16_le (data + offset + 0); unsigned int depth = array_uint16_le (data + offset + 0);
sample.depth = (depth * BAR / 1000.0 - atmospheric) / parser->hydrostatic; sample.depth = (signed int)(depth - atmospheric) * (BAR / 1000.0) / parser->hydrostatic;
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Pressure (1 psi). // Pressure (1 psi).

View File

@ -33,6 +33,10 @@
#define ISINSTANCE(device) dc_device_isinstance((device), &hw_ostc3_device_vtable) #define ISINSTANCE(device) dc_device_isinstance((device), &hw_ostc3_device_vtable)
#define OSTC3FW(major,minor) ( \
(((major) & 0xFF) << 8) | \
((minor) & 0xFF))
#define SZ_DISPLAY 16 #define SZ_DISPLAY 16
#define SZ_CUSTOMTEXT 60 #define SZ_CUSTOMTEXT 60
#define SZ_VERSION (SZ_CUSTOMTEXT + 4) #define SZ_VERSION (SZ_CUSTOMTEXT + 4)
@ -1282,10 +1286,13 @@ hw_ostc3_firmware_block_write2 (hw_ostc3_device_t *device, unsigned int address,
static dc_status_t static dc_status_t
hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int address, const unsigned char data[], unsigned int size) hw_ostc3_firmware_block_write (hw_ostc3_device_t *device, unsigned int address, const unsigned char data[], unsigned int size)
{ {
if (device->firmware >= 0x0309) { // Support for the S_BLOCK_WRITE2 command is only available since the
return hw_ostc3_firmware_block_write2 (device, address, data, size); // hwOS Tech firmware v3.09 and the hwOS Sport firmware v10.64.
} else { if ((device->firmware < OSTC3FW(3,9)) ||
(device->firmware >= OSTC3FW(10,0) && device->firmware < OSTC3FW(10,64))) {
return hw_ostc3_firmware_block_write1 (device, address, data, size); return hw_ostc3_firmware_block_write1 (device, address, data, size);
} else {
return hw_ostc3_firmware_block_write2 (device, address, data, size);
} }
} }

View File

@ -31,6 +31,10 @@
#define ISINSTANCE(parser) dc_parser_isinstance((parser), &mares_iconhd_parser_vtable) #define ISINSTANCE(parser) dc_parser_isinstance((parser), &mares_iconhd_parser_vtable)
#define OBJVERSION(major,minor) ( \
(((major) & 0xFF) << 8) | \
((minor) & 0xFF))
#define SMART 0x000010 #define SMART 0x000010
#define SMARTAPNEA 0x010010 #define SMARTAPNEA 0x010010
#define ICONHD 0x14 #define ICONHD 0x14
@ -374,7 +378,7 @@ mares_genius_cache (mares_iconhd_parser_t *parser)
unsigned int type = array_uint16_le (data); unsigned int type = array_uint16_le (data);
unsigned int minor = data[2]; unsigned int minor = data[2];
unsigned int major = data[3]; unsigned int major = data[3];
if (type != 1 || major != 0 || minor > 1) { if (type != 1 || OBJVERSION(major,minor) > OBJVERSION(1,1)) {
ERROR (abstract->context, "Unsupported object type (%u) or version (%u.%u).", ERROR (abstract->context, "Unsupported object type (%u) or version (%u.%u).",
type, major, minor); type, major, minor);
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
@ -389,8 +393,14 @@ mares_genius_cache (mares_iconhd_parser_t *parser)
extra = 8; extra = 8;
} }
// The Genius header (v1.x) has 10 bytes more at the end.
unsigned int more = 0;
if (major == 1) {
more = 16;
}
// Get the header size. // Get the header size.
unsigned int headersize = 0xB8 + extra; unsigned int headersize = 0xB8 + extra + more;
if (headersize > size) { if (headersize > size) {
ERROR (abstract->context, "Buffer overflow detected!"); ERROR (abstract->context, "Buffer overflow detected!");
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
@ -869,7 +879,9 @@ mares_iconhd_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
unsigned int type = array_uint16_le (data); unsigned int type = array_uint16_le (data);
unsigned int minor = data[2]; unsigned int minor = data[2];
unsigned int major = data[3]; unsigned int major = data[3];
if (type > 1 || major != 0 || minor != 2) { if (type > 1 ||
(type == 0 && OBJVERSION(major,minor) > OBJVERSION(1,0)) ||
(type == 1 && OBJVERSION(major,minor) > OBJVERSION(0,2))) {
ERROR (abstract->context, "Unsupported object type (%u) or version (%u.%u).", ERROR (abstract->context, "Unsupported object type (%u) or version (%u.%u).",
type, major, minor); type, major, minor);
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;

View File

@ -22,6 +22,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <libdivecomputer/units.h>
#include "mclean_extreme.h" #include "mclean_extreme.h"
#include "context-private.h" #include "context-private.h"
#include "parser-private.h" #include "parser-private.h"
@ -152,19 +154,19 @@ mclean_extreme_parser_get_field(dc_parser_t *abstract, dc_field_type_t type, uns
dc_gasmix_t *gasmix = (dc_gasmix_t *)value; dc_gasmix_t *gasmix = (dc_gasmix_t *)value;
dc_salinity_t *salinity = (dc_salinity_t *)value; dc_salinity_t *salinity = (dc_salinity_t *)value;
const unsigned int psurf = array_uint16_le(abstract->data + 0x001E); const unsigned int atmospheric = array_uint16_le(abstract->data + 0x001E);
const unsigned int density_index = abstract->data[0x0023]; const unsigned int density_index = abstract->data[0x0023];
double density = 0; double density = 0;
switch (density_index) { switch (density_index) {
case 0: case 0:
density = 1.000; density = 1000.0;
break; break;
case 1: case 1:
density = 1.020; density = 1020.0;
break; break;
case 2: case 2:
density = 1.030; density = 1030.0;
break; break;
default: default:
ERROR(abstract->context, "Corrupt density index in dive data"); ERROR(abstract->context, "Corrupt density index in dive data");
@ -177,17 +179,17 @@ mclean_extreme_parser_get_field(dc_parser_t *abstract, dc_field_type_t type, uns
*((unsigned int *)value) = array_uint32_le(abstract->data + SZ_CFG + 0x000C) - array_uint32_le(abstract->data + SZ_CFG + 0x0000); *((unsigned int *)value) = array_uint32_le(abstract->data + SZ_CFG + 0x000C) - array_uint32_le(abstract->data + SZ_CFG + 0x0000);
break; break;
case DC_FIELD_MAXDEPTH: case DC_FIELD_MAXDEPTH:
*((double *)value) = 0.01 * (array_uint16_le(abstract->data + SZ_CFG + 0x0016) - psurf) / density; *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0016) - atmospheric) * (BAR / 1000.0) / (density * GRAVITY);
break; break;
case DC_FIELD_AVGDEPTH: case DC_FIELD_AVGDEPTH:
*((double *)value) = 0.01 * (array_uint16_le(abstract->data + SZ_CFG + 0x0018) - psurf) / density; *((double *)value) = (signed int)(array_uint16_le(abstract->data + SZ_CFG + 0x0018) - atmospheric) * (BAR / 1000.0) / (density * GRAVITY);
break; break;
case DC_FIELD_SALINITY: case DC_FIELD_SALINITY:
salinity->density = density * 1000.0; salinity->density = density;
salinity->type = density_index == 0 ? DC_WATER_FRESH : DC_WATER_SALT; salinity->type = density_index == 0 ? DC_WATER_FRESH : DC_WATER_SALT;
break; break;
case DC_FIELD_ATMOSPHERIC: case DC_FIELD_ATMOSPHERIC:
*((double *)value) = 0.001 * array_uint16_le(abstract->data + 0x001E); *((double *)value) = atmospheric / 1000.0;
break; break;
case DC_FIELD_TEMPERATURE_MINIMUM: case DC_FIELD_TEMPERATURE_MINIMUM:
*((double *)value) = (double)abstract->data[SZ_CFG + 0x0010]; *((double *)value) = (double)abstract->data[SZ_CFG + 0x0010];

View File

@ -925,7 +925,7 @@ shearwater_predator_parser_samples_foreach (dc_parser_t *abstract, dc_sample_cal
// Depth (absolute pressure in millibar) // Depth (absolute pressure in millibar)
unsigned int depth = array_uint16_be (data + idx + 1); unsigned int depth = array_uint16_be (data + idx + 1);
sample.depth = (depth - parser->atmospheric) * (BAR / 1000.0) / (parser->density * GRAVITY); sample.depth = (signed int)(depth - parser->atmospheric) * (BAR / 1000.0) / (parser->density * GRAVITY);
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
// Temperature (1/10 °C). // Temperature (1/10 °C).

View File

@ -342,22 +342,14 @@ sporasub_sp2_device_read (dc_device_t *abstract, unsigned int address, unsigned
static dc_status_t static dc_status_t
sporasub_sp2_device_dump (dc_device_t *abstract, dc_buffer_t *buffer) sporasub_sp2_device_dump (dc_device_t *abstract, dc_buffer_t *buffer)
{ {
sporasub_sp2_device_t *device = (sporasub_sp2_device_t *) abstract;
// Allocate the required amount of memory. // Allocate the required amount of memory.
if (!dc_buffer_resize (buffer, SZ_MEMORY)) { if (!dc_buffer_resize (buffer, SZ_MEMORY)) {
ERROR (abstract->context, "Insufficient buffer space available."); ERROR (abstract->context, "Insufficient buffer space available.");
return DC_STATUS_NOMEMORY; return DC_STATUS_NOMEMORY;
} }
return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), SZ_READ);
}
static dc_status_t
sporasub_sp2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata)
{
dc_status_t status = DC_STATUS_SUCCESS;
sporasub_sp2_device_t *device = (sporasub_sp2_device_t *) abstract;
// Emit a device info event. // Emit a device info event.
dc_event_devinfo_t devinfo; dc_event_devinfo_t devinfo;
devinfo.model = 0; devinfo.model = 0;
@ -371,6 +363,16 @@ sporasub_sp2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback,
vendor.size = sizeof (device->version); vendor.size = sizeof (device->version);
device_event_emit (abstract, DC_EVENT_VENDOR, &vendor); device_event_emit (abstract, DC_EVENT_VENDOR, &vendor);
return device_dump_read (abstract, dc_buffer_get_data (buffer),
dc_buffer_get_size (buffer), SZ_READ);
}
static dc_status_t
sporasub_sp2_device_foreach (dc_device_t *abstract, dc_dive_callback_t callback, void *userdata)
{
dc_status_t status = DC_STATUS_SUCCESS;
sporasub_sp2_device_t *device = (sporasub_sp2_device_t *) abstract;
dc_buffer_t *buffer = dc_buffer_new (SZ_MEMORY); dc_buffer_t *buffer = dc_buffer_new (SZ_MEMORY);
if (buffer == NULL) { if (buffer == NULL) {
status = DC_STATUS_NOMEMORY; status = DC_STATUS_NOMEMORY;

View File

@ -112,9 +112,13 @@ sporasub_sp2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
const unsigned char *data = abstract->data; const unsigned char *data = abstract->data;
unsigned int size = abstract->size; unsigned int size = abstract->size;
dc_salinity_t *water = (dc_salinity_t *) value;
if (size < SZ_HEADER) if (size < SZ_HEADER)
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
unsigned int settings = data[0x1A];
if (value) { if (value) {
switch (type) { switch (type) {
case DC_FIELD_DIVETIME: case DC_FIELD_DIVETIME:
@ -132,6 +136,10 @@ sporasub_sp2_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
case DC_FIELD_TEMPERATURE_MAXIMUM: case DC_FIELD_TEMPERATURE_MAXIMUM:
*((double *) value) = array_uint16_le (data + 0x16) / 10.0; *((double *) value) = array_uint16_le (data + 0x16) / 10.0;
break; break;
case DC_FIELD_SALINITY:
water->type = settings & 0x08 ? DC_WATER_FRESH : DC_WATER_SALT;
water->density = 0.0;
break;
default: default:
return DC_STATUS_UNSUPPORTED; return DC_STATUS_UNSUPPORTED;
} }
@ -151,9 +159,10 @@ sporasub_sp2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
return DC_STATUS_DATAFORMAT; return DC_STATUS_DATAFORMAT;
unsigned int nsamples = array_uint16_le(data); unsigned int nsamples = array_uint16_le(data);
unsigned int settings = data[0x1A];
// Get the sample interval. // Get the sample interval.
unsigned int interval_idx = data[0x1A]; unsigned int interval_idx = settings & 0x03;
const unsigned int intervals[] = {1, 2, 5, 10}; const unsigned int intervals[] = {1, 2, 5, 10};
if (interval_idx >= C_ARRAY_SIZE(intervals)) { if (interval_idx >= C_ARRAY_SIZE(intervals)) {
ERROR (abstract->context, "Invalid sample interval index %u", interval_idx); ERROR (abstract->context, "Invalid sample interval index %u", interval_idx);
@ -170,8 +179,7 @@ sporasub_sp2_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t
unsigned int value = array_uint32_le (data + offset); unsigned int value = array_uint32_le (data + offset);
unsigned int heartrate = (value & 0xFF000000) >> 24; unsigned int heartrate = (value & 0xFF000000) >> 24;
unsigned int temperature = (value & 0x00FFC000) >> 14; unsigned int temperature = (value & 0x00FFC000) >> 14;
unsigned int unknown = (value & 0x00003000) >> 12; unsigned int depth = (value & 0x00003FFF) >> 0;
unsigned int depth = (value & 0x00000FFF) >> 0;
// Time (seconds) // Time (seconds)
time += interval; time += interval;

View File

@ -62,8 +62,8 @@
#define HEADER 1 #define HEADER 1
#define PROFILE 2 #define PROFILE 2
#define FRESH 1.000 #define FRESH 1000.0
#define SALT 1.025 #define SALT 1025.0
#define FREEDIVE 0x00000080 #define FREEDIVE 0x00000080
#define GAUGE 0x00001000 #define GAUGE 0x00001000
@ -789,7 +789,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
const uwatec_smart_header_info_t *table = parser->header; const uwatec_smart_header_info_t *table = parser->header;
const unsigned char *data = abstract->data; const unsigned char *data = abstract->data;
double salinity = (parser->watertype == DC_WATER_SALT ? SALT : FRESH); double density = (parser->watertype == DC_WATER_SALT ? SALT : FRESH);
dc_gasmix_t *gasmix = (dc_gasmix_t *) value; dc_gasmix_t *gasmix = (dc_gasmix_t *) value;
dc_tank_t *tank = (dc_tank_t *) value; dc_tank_t *tank = (dc_tank_t *) value;
@ -801,7 +801,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
*((unsigned int *) value) = array_uint16_le (data + table->divetime) * 60; *((unsigned int *) value) = array_uint16_le (data + table->divetime) * 60;
break; break;
case DC_FIELD_MAXDEPTH: case DC_FIELD_MAXDEPTH:
*((double *) value) = array_uint16_le (data + table->maxdepth) / 100.0 / salinity; *((double *) value) = array_uint16_le (data + table->maxdepth) * (BAR / 1000.0) / (density * GRAVITY);
break; break;
case DC_FIELD_GASMIX_COUNT: case DC_FIELD_GASMIX_COUNT:
*((unsigned int *) value) = parser->ngasmixes; *((unsigned int *) value) = parser->ngasmixes;
@ -844,7 +844,7 @@ uwatec_smart_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi
if (table->settings == UNSUPPORTED) if (table->settings == UNSUPPORTED)
return DC_STATUS_UNSUPPORTED; return DC_STATUS_UNSUPPORTED;
water->type = parser->watertype; water->type = parser->watertype;
water->density = salinity * 1000.0; water->density = density;
break; break;
default: default:
return DC_STATUS_UNSUPPORTED; return DC_STATUS_UNSUPPORTED;
@ -940,9 +940,9 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
unsigned int rbt = 99; unsigned int rbt = 99;
unsigned int tank = 0; unsigned int tank = 0;
unsigned int gasmix = 0; unsigned int gasmix = 0;
double depth = 0, depth_calibration = 0; unsigned int depth = 0, depth_calibration = 0;
double temperature = 0; int temperature = 0;
double pressure = 0; unsigned int pressure = 0;
unsigned int heartrate = 0; unsigned int heartrate = 0;
unsigned int bearing = 0; unsigned int bearing = 0;
unsigned int bookmark = 0; unsigned int bookmark = 0;
@ -950,7 +950,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
// Previous gas mix - initialize with impossible value // Previous gas mix - initialize with impossible value
unsigned int gasmix_previous = 0xFFFFFFFF; unsigned int gasmix_previous = 0xFFFFFFFF;
double salinity = (parser->watertype == DC_WATER_SALT ? SALT : FRESH); double density = (parser->watertype == DC_WATER_SALT ? SALT : FRESH);
unsigned int interval = 4; unsigned int interval = 4;
if (parser->divemode == DC_DIVEMODE_FREEDIVE) { if (parser->divemode == DC_DIVEMODE_FREEDIVE) {
@ -1026,8 +1026,8 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
const uwatec_smart_event_info_t *events = NULL; const uwatec_smart_event_info_t *events = NULL;
switch (table[id].type) { switch (table[id].type) {
case PRESSURE_DEPTH: case PRESSURE_DEPTH:
pressure += ((signed char) ((svalue >> NBITS) & 0xFF)) / 4.0; pressure += (signed char) ((svalue >> NBITS) & 0xFF);
depth += ((signed char) (svalue & 0xFF)) / 50.0; depth += (signed char) (svalue & 0xFF);
complete = 1; complete = 1;
break; break;
case RBT: case RBT:
@ -1040,37 +1040,37 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
break; break;
case TEMPERATURE: case TEMPERATURE:
if (table[id].absolute) { if (table[id].absolute) {
temperature = svalue / 2.5; temperature = svalue;
have_temperature = 1; have_temperature = 1;
} else { } else {
temperature += svalue / 2.5; temperature += svalue;
} }
break; break;
case PRESSURE: case PRESSURE:
if (table[id].absolute) { if (table[id].absolute) {
if (parser->trimix) { if (parser->trimix) {
tank = (value & 0xF000) >> 12; tank = (value & 0xF000) >> 12;
pressure = (value & 0x0FFF) / 4.0; pressure = (value & 0x0FFF);
} else { } else {
tank = table[id].index; tank = table[id].index;
pressure = value / 4.0; pressure = value;
} }
have_pressure = 1; have_pressure = 1;
gasmix = tank; gasmix = tank;
} else { } else {
pressure += svalue / 4.0; pressure += svalue;
} }
break; break;
case DEPTH: case DEPTH:
if (table[id].absolute) { if (table[id].absolute) {
depth = value / 50.0; depth = value;
if (!calibrated) { if (!calibrated) {
calibrated = 1; calibrated = 1;
depth_calibration = depth; depth_calibration = depth;
} }
have_depth = 1; have_depth = 1;
} else { } else {
depth += svalue / 50.0; depth += svalue;
} }
complete = 1; complete = 1;
break; break;
@ -1195,7 +1195,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
} }
if (have_temperature) { if (have_temperature) {
sample.temperature = temperature; sample.temperature = temperature / 2.5;
if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata); if (callback) callback (DC_SAMPLE_TEMPERATURE, sample, userdata);
} }
@ -1216,7 +1216,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
idx = uwatec_smart_find_tank(parser, tank); idx = uwatec_smart_find_tank(parser, tank);
if (idx < parser->ntanks) { if (idx < parser->ntanks) {
sample.pressure.tank = idx; sample.pressure.tank = idx;
sample.pressure.value = pressure; sample.pressure.value = pressure / 4.0;
if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata); if (callback) callback (DC_SAMPLE_PRESSURE, sample, userdata);
} }
} }
@ -1233,7 +1233,7 @@ uwatec_smart_parse (uwatec_smart_parser_t *parser, dc_sample_callback_t callback
} }
if (have_depth) { if (have_depth) {
sample.depth = (depth - depth_calibration) / salinity; sample.depth = (signed int)(depth - depth_calibration) * (2.0 * BAR / 1000.0) / (density * GRAVITY);
if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata); if (callback) callback (DC_SAMPLE_DEPTH, sample, userdata);
} }